Search Results

Search found 60 results on 3 pages for 'bjorn'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • Load django template from the database

    - by Björn Lindqvist
    Hello, Im trying to render a django template from a database outside of djangos normal request-response structure. But it appears to be non-trivial due to the way django templates are compiled. I want to do something like this: >>> s = Template.objects.get(pk = 123).content >>> some_method_to_render(s, {'a' : 123, 'b' : 456}) >>> ... the rendered output here ... How do you do this?

    Read the article

  • How do you efficiently implement a document similarity search system?

    - by Björn Lindqvist
    How do you implement a "similar items" system for items described by a set of tags? In my database, I have three tables, Article, ArticleTag and Tag. Each Article is related to a number of Tags via a many-to-many relationship. For each Article i want to find the five most similar articles to implement a "if you like this article you will like these too" system. I am familiar with Cosine similarity and using that algorithm works very well. But it is way to slow. For each article, I need to iterate over all articles, calculate the cosine similarity for the article pair and then select the five articles with the highest similarity rating. With 200k articles and 30k tags, it takes me half a minute to calculate the similar articles for a single article. So I need another algorithm that produces roughly as good results as cosine similarity but that can be run in realtime and which does not require me to iterate over the whole document corpus each time. Maybe someone can suggest an off-the-shelf solution for this? Most of the search engines I looked at does not enable document similarity searching.

    Read the article

  • jaxb XmlAccessType: PROPERTY example

    - by Bjorn J
    I'm trying to use jaxb and want to use the 'XmlAccessType.PROPERTY' to let jaxb use getters/setters rather than variable directly, but get different errors depending on what I try, or the variable isn't set at all like I want. Any good link or pointer to a simple example? For example, the below makes the groupDefintion not to be set when parsing the xml document: @XmlAccessorType(javax.xml.bind.annotation.XmlAccessType.PROPERTY) public class E { private EGroup groupDefinition; public EGroup getGroupDefinition () { return groupDefinition; } @XmlAttribute public void setGroupDefinition (EGroup g) { groupDefinition = g; } }

    Read the article

  • Select XML nodes as rows

    - by Bjørn
    I am selecting from a table that has an XML column using T-SQL. I would like to select a certain type of node and have a row created for each one. For instance, suppose I am selecting from a people table. This table has an XML column for addresses. The XML is formated similar to the following: <address> <street>Street 1</street> <city>City 1</city> <state>State 1</state> <zipcode>Zip Code 1</zipcode> </address> <address> <street>Street 2</street> <city>City 2</city> <state>State 2</state> <zipcode>Zip Code 2</zipcode> </address> How can I get results like this: Name         City         State Joe Baker   Seattle      WA Joe Baker   Tacoma     WA Fred Jones  Vancouver BC

    Read the article

  • Working with NSCalendar -- getting the next first tuesday of a month

    - by Bjorn S.
    Hi all, This is a bit odd, but is it possible to use an NSCalendar (or any component, for that matter) to figure out what the date of the next "first tuesday of the month" would be? For example, today is Thursday March 25, 2010. The next "first tuesday of the month" would be on April 6. Likewise, if I were looking for the next "first tuesday of the month" on April 1, it would still be on April 6. How would you do this? Thanks very much!!!!!

    Read the article

  • Is AsParallel() good practice in a web environment?

    - by Bjorn Bailleul
    I have no doubt that for client applications, AsParallel() will bring some out-of-the-box performance gains. But what if I would use it in a web environment. Let's say I have a widget framework that loops over all widgets to get their data and render output. This would parallelize great no? I do have my doubts on using AsParallel() in this scenario. What if I have a large number of visitors for my site, isn't IIS going to use multiple threads to handle all requests? Aren't there going to be locking issues presented after a while, or threads dying because all processors are in use? It's just a thought, what do you think about this?

    Read the article

  • MySQL nested set hierarchy with foreign table

    - by Björn
    Hi! I'm using a nested set in a MySQL table to describe a hierarchy of categories, and an additional table describing products. Category table; id name left right Products table; id categoryId name How can I retrieve the full path, containing all parent categories, of a product? I.e.: RootCategory > SubCategory 1 > SubCategory 2 > ... > SubCategory n > Product Say for example that I want to list all products from SubCategory1 and it's sub categories, and with each given Product I want the full tree path to that product - is this possible? This is as far as I've got - but the structure is not quite right... select parent.`name` as name, parent.`id` as id, group_concat(parent.`name` separator '/') as path from categories as node, categories as parent, (select inode.`id` as id, inode.`name` as name from categories as inode, categories as iparent where inode.`lft` between iparent.`lft` and iparent.`rgt` and iparent.`id`=4 /* The category from which to list products */ order by inode.`lft`) as sub where node.`lft` between parent.`lft` and parent.`rgt` and node.`id`=sub.`id` group by sub.`id` order by node.`lft`

    Read the article

  • CVS tools for repo monitoring on windows?

    - by Bjorn J
    I sometime use the very simple but effective svncommitmonitor, http://tools.tortoisesvn.net/CommitMonitor to monitor activity. It's easy to see in the sys tray on a windows box and I've become used to it by now. So, is there a similar/identical tool for CVS. Some googling and to my surprise I couldn't find one. Any tips?

    Read the article

  • Efficiently finding the shortest path in large graphs

    - by Björn Lindqvist
    I'm looking to find a way to in real-time find the shortest path between nodes in a huge graph. It has hundreds of thousands of vertices and millions of edges. I know this question has been asked before and I guess the answer is to use a breadth-first search, but I'm more interested in to know what software you can use to implement it. For example, it would be totally perfect if it already exist a library (with python bindings!) for performing bfs in undirected graphs.

    Read the article

  • Scalability comparison between different DBMSs

    - by Björn Lindfors
    By what factor does the performance (read queries/sec) increase when a machine is added to a cluster of machines running either: a Bigtable-like database MySQL? Google's research paper on Bigtable suggests that "near-linear" scaling is achieved can be achieved with Bigtable. This page here featuring MySQL's marketing jargon suggests that MySQL is capable of scaling linearly. Where is the truth?

    Read the article

  • Displaying Photos on iPhone

    - by Bjorn S.
    Hi all, I'm working on an iPhone app and I need to be able to display images to users. I have already gotten the code that takes the photo and stores it into the filesystem working well. Now I just need to figure out how to display the image. I've looked at the Three20 project I've read about on a few of the posts here, but it seems a bit cumbersome and like an extra dependency to import link and combine all of the Three20 library into my little app. Are there any other ways or a more streamlined library that will let me display photos to my users? Thanks! B.

    Read the article

  • Django: problem with merging querysets after annotation

    - by Björn Lilja
    Hi I have a manager for "Dialog" looking like this: class AnnotationManager(models.Manager): def get_query_set(self): return super(AnnotationManager, self).get_query_set().annotate( num_votes=Count('vote', distinct=True), num_comments=Count('comment', distinct=True), num_commentators = Count('comment__user', distinct=True), ) Votes and Comments has a ForeignKey to Dialog. Comments has a ForeignKey to User. When I do this: dialogs_queryset = Dialog.public.filter(organization=organization) dialogs_popularity = dialogs_queryset.exclude(num_comments=0) | dialogs_queryset.exclude(num_votes=0) ...dialogs_popularity will never returned the combination, but only the dialogs with more than 0 comments, or if I change the order of the OR, the dialogs with more than 0 votes! To me, the expected behavior would be to get the dialogs with more than 0 votes AND the dialogs with more than 0 comments. What am I missing? Or is there a bug in the annotation behavior here?

    Read the article

  • Installing Ruby 1.9.1 on Ubuntu?

    - by Björn
    I wonder about installing the latest version of Ruby on Ubuntu 9.04. Now I can run through the ./configure and make stuff fine, but what I wonder about: how to avoid conflicts with the packaging system? For example if some other package I install depends on Ruby, wouldn't the package manager install the (outdated) Ruby package and in the worst case overwrite my files? So I think I need some way to tell Ubuntu that Ruby is in fact already installed?

    Read the article

  • Best way to store data for Greasemonkey based crawler?

    - by Björn
    I want to crawl a site with Greasemonkey and wonder if there is a better way to temporarily store values than with GM_setValue. What I want to do is crawl my contacts in a social network and extract the Twitter URLs from their profile pages. My current plan is to open each profile in it's own tab, so that it looks more like a normal browsing person (ie css, scrits and images will be loaded by the browser). Then store the Twitter URL with GM_setValue. Once all profile pages have been crawled, create a page using the stored values. I am not so happy with the storage option, though. Maybe there is a better way? I have considered inserting the user profiles into the current page so that I could all process them with the same script instance, but I am not sure if XMLHttpRequest looks indistignuishable from normal user initiated requests.

    Read the article

  • jQuery: Show and hide child div when hovering

    - by Björn
    Hi there, I've got a set of items. Each item has two images and some text. For the images I've created a parent div which has an overflow:hidden CSS value. I want to achieve an mouseover effect. As soon as you hover over the images I want to hide the current div and show the second div. Here's a small snippet: <div class="product-images"> <div class="product-image-1"><img src="image1.gif>" /></div> <div class="product-image-2"><img src="images2.gif" /></div> </div> I've created a small jQuery snippet: jQuery(document).ready(function() { jQuery('.product-images').mouseover(function() { jQuery('.product-image-1').hide(); }).mouseout(function() { jQuery('.product-image-1').show(); }); }); Now the problem is that not only the currently hovered child is hidden. Instead all other existing childs are hidden as well. I need something like "this" or "current" but I don't know which jQuery function is the right one. Any idea? Thanks, BJ

    Read the article

  • Core Data: Fetch all entities in a to-many-relationship of a particular object?

    - by Björn Marschollek
    Hi there, in my iPhone application I am using simple Core Data Model with two entities (Item and Property): Item name properties Property name value item Item has one attribute (name) and one one-to-many-relationship (properties). Its inverse relationship is item. Property has two attributes the according inverse relationship. Now I want to show my data in table views on two levels. The first one lists all items; when one row is selected, a new UITableViewController is pushed onto my UINavigationController's stack. The new UITableView is supposed to show all properties (i.e. their names) of the selected item. To achieve this, I use a NSFetchedResultsController stored in an instance variable. On the first level, everything works fine when setting up the NSFetchedResultsController like this: -(NSFetchedResultsController *) fetchedResultsController { if (fetchedResultsController) return fetchedResultsController; // goal: tell the FRC to fetch all item objects. NSFetchRequest *fetch = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Item" inManagedObjectContext:self.moContext]; [fetch setEntity:entity]; NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES]; [fetch setSortDescriptors:[NSArray arrayWithObject:sort]]; [fetch setFetchBatchSize:10]; NSFetchedResultsController *frController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetch managedObjectContext:self.moContext sectionNameKeyPath:nil cacheName:@"cache"]; self.fetchedResultsController = frController; fetchedResultsController.delegate = self; [sort release]; [frController release]; [fetch release]; return fetchedResultsController; } However, on the second-level UITableView, I seem to do something wrong. I implemented the fetchedresultsController in a similar way: -(NSFetchedResultsController *) fetchedResultsController { if (fetchedResultsController) return fetchedResultsController; // goal: tell the FRC to fetch all property objects that belong to the previously selected item NSFetchRequest *fetch = [[NSFetchRequest alloc] init]; // fetch all Property entities. NSEntityDescription *entity = [NSEntityDescription entityForName:@"Property" inManagedObjectContext:self.moContext]; [fetch setEntity:entity]; // limit to those entities that belong to the particular item NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"item.name like '%@'",self.item.name]]; [fetch setPredicate:predicate]; // sort it. Boring. NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES]; [fetch setSortDescriptors:[NSArray arrayWithObject:sort]]; NSError *error = nil; NSLog(@"%d entities found.",[self.moContext countForFetchRequest:fetch error:&error]); // logs "3 entities found."; I added those properties before. See below for my saving "problem". if (error) NSLog("%@",error); // no error, thus nothing logged. [fetch setFetchBatchSize:20]; NSFetchedResultsController *frController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetch managedObjectContext:self.moContext sectionNameKeyPath:nil cacheName:@"cache"]; self.fetchedResultsController = frController; fetchedResultsController.delegate = self; [sort release]; [frController release]; [fetch release]; return fetchedResultsController; } Now it's getting weird. The above NSLog statement returns me the correct number of properties for the selected item. However, the UITableViewDelegate method tells me that there are no properties: -(NSInteger) tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section { id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section]; NSLog(@"Found %d properties for item \"%@\". Should have found %d.",[sectionInfo numberOfObjects], self.item.name, [self.item.properties count]); // logs "Found 0 properties for item "item". Should have found 3." return [sectionInfo numberOfObjects]; } The same implementation works fine on the first level. It's getting even weirder. I implemented some kind of UI to add properties. I create a new Property instance via Property *p = [NSEntityDescription insertNewObjectForEntityForName:@"Property" inManagedObjectContext:self.moContext];, set up the relationships and call [self.moContext save:&error]. This seems to work, as error is still nil and the object gets saved (I can see the number of properties when logging the Item instance, see above). However, the delegate methods are not fired. This seems to me due to the possibly messed up fetchRequest(Controller). Any ideas? Did I mess up the second fetch request? Is this the right way to fetch all entities in a to-many-relationship for a particular instance at all?

    Read the article

  • Updating a TextView with a SeekBar's value (ultra-slow)

    - by Peter Bjorn
    Now look at that! I am having trouble with one of the simplest goals: updating a plain TextView with the value of a SeekBar. This is my approach: @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { mInfoText.setText(mFunction.getUserFriendlyString(progress)); } } It basically works, but it kind of blocks the whole UI when I'm dragging. (Note: I tried both View.post() and Activity.runOnUiThread()). Am I overlooking something?

    Read the article

  • How to suppress error messages in rpy2

    - by Björn
    Hello! The following code does not work. It seems that the R warning message raises a python error. # enable use of python objects in rpy2 import rpy2.robjects.numpy2ri import numpy as np from rpy2.robjects import r # create an example array a = np.array([[5,2,5],[3,7,8]]) # this line leads to a warning message, which in turn raises an # error message if run within a script. result = r['chisq.test'](a) Running that code example in ipython works, however, running it inside a script raises the errorTypeError: 'module' object is unsubscriptable. I assume this is due to the warning message. What is the best way to avoid this problem? Thanks in advance!

    Read the article

  • for loop will not loop

    - by Bjørn Jostein Aurheim
    I have a for loop that I will use to compute time intervals to add to an ArrayList. The problem is that I can not prove that the for loop is being executed. Nothing is printed when using the system.out.println() statement, and nothing is added to the array from inside the loop ... any sugestions? // lager tidspunkter og legger disse inn i en Array kalt tider tid.setTimer(16); tid.setMinutter(0); tid.setSekunder(0); tider.add(tid.asString());// String "16:00" is added as it should System.out.println("tiden er: "+tid.asString());// gives 16:00 printed for(int i=0;i>12;i++){ System.out.println("er i løkken");// gives nothing printed tid.increaseMinutter(30); System.out.println(tid.asString());// gives nothing printed tider.add(tid.asString()); }

    Read the article

  • How do you pause before fading an element out using jQuery?

    - by Bjørn
    I would like to flash a success message on my page. I am using the jQuery fadeOut method to fade and then remove the element. I can increase the duration to make it last longer, however this looks strange. What I would like to happen is have the element be displayed for five seconds, then fade quickly, and finally be removed. How can you animate this using jQuery?

    Read the article

  • How to make pytest display a custom string representation for fixture parameters?

    - by Björn Pollex
    When using builtin types as fixture parameters, pytest prints out the value of the parameters in the test report. For example: @fixture(params=['hello', 'world'] def data(request): return request.param def test_something(data): pass Running this with py.test --verbose will print something like: test_example.py:7: test_something[hello] PASSED test_example.py:7: test_something[world] PASSED Note that the value of the parameter is printed in square brackets after the test name. Now, when using an object of a user-defined class as parameter, like so: class Param(object): def __init__(self, text): self.text = text @fixture(params=[Param('hello'), Param('world')] def data(request): return request.param def test_something(data): pass pytest will simply enumerate the number of values (p0, p1, etc.): test_example.py:7: test_something[p0] PASSED test_example.py:7: test_something[p1] PASSED This behavior does not change even when the user-defined class provides custom __str__ and __repr__ implementations. Is there any way to make pytest display something more useful than just p0 here? I am using pytest 2.5.2 on Python 2.7.6 on Windows 7.

    Read the article

  • Getting the eventargs of registered events

    - by Bjorn Vdkerckhove
    i'm new with maps and openlayers, but i'm playing around with openlayers because i'll need mapfunctionality in my next project. The map is an image (because it's a drawn map of a medieval town). I found how i can register events, and it's working. But the problem is, that the "eventargs" is not working as in the examples i found. In one of the examples they are getting the x and y values after the users panned like this: map.events.register('moveend', map, function (e) { alert(e.xy); }); If i try this in visual studio, e doesn't have a 'xy' property. What am i missing? This is the code i have right now: <script type="text/javascript"> var map, layer; function init() { var windowHeight = $(window).height(); var windowWidth = $(window).width(); var mapdiv = $('#map'); mapdiv.css({width: windowWidth + 'px', height: windowHeight + 'px'}); map = new OpenLayers.Map('map', { maxResolution: 1000 }); layer = new OpenLayers.Layer.Image( 'Globe ESA', '[url]', new OpenLayers.Bounds(-180.0, -12333.5, 21755.5, 90.0), new OpenLayers.Size(windowWidth, windowHeight), { numZoomLevels: 100 }); map.addLayer(layer); nav = new OpenLayers.Control.Navigation(); map.addControl(nav); //events test map.events.register('moveend', map, function (e) { alert(e.xy); }); map.zoomToMaxExtent(); } </script> In the examples of openlayer, they don't use the eventargs, but there must be a way to get the zoomlevel, or the x and y after panning, right? Thank you!

    Read the article

  • Postfix character encoding?

    - by Anonymous12345
    I use Postfix as a mailserver. I have Ubuntu OS. Then I use PHP to send emails. Problem is that none of my emails are encoded properly by a mailsoftware which my VPS provider uses. According to them, the problem lies with me. It is only the name field which isn't encoded properly. For example "Björn" becomes "Björn" in my emails. However, when I echo the $name, it outputs "Björn" which is correct. Also, gmail and hotmail does show it correctly. The strange part is that the "text" (the message itself) is encoded properly. I use the following for sending mail: $headers="MIME-Version: 1.0"."\n"; $headers.="Content-type: text/plain; charset=UTF-8"."\n"; $headers.="From: $name <$email>"."\n"; $name= iconv(mb_detect_encoding($name), "UTF-8//IGNORE//TRANSLIT", $name); //// I HAVE TRIED WITH AND WITHOUT THE LINE ABOVE, NO DIFFERENCE mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $text, $headers, '[email protected]'); I have tried with and without the iconv line also, no luck. The last thing I can think of is POSTFIX, could there be a setting for character encoding there? Anybody knows?

    Read the article

< Previous Page | 1 2 3  | Next Page >