I have a custom template tag:
def uploads_for_user(user):
uploads = Uploads.objects.filter(uploaded_by=user, problem_upload=False)
num_uploads = uploads.count()
return num_uploads
and I'd like to do something like this, so I can pluralize properly:
{% with uploads_for_user leader as upload_count %}
{{ upload_count }} upload{{ upload_count|pluralize }}
{% endwith %}
However, uploads_for_user leader doesn't work in this context, because the 'with' tag expects a single value - Django returns:
TemplateSyntaxError at /upload/
u'with' expected format is 'value as name'
Any idea how I can get round this?
XML spec defines a subset of Unicode characters which are allowed in XML documents:
http://www.w3.org/TR/REC-xml/#charsets.
How do I filter out these characters from a String in Java?
simple test case:
Assert.equals("", filterIllegalXML(""+Character.valueOf((char) 2)))
How can you select an element that has current focus?
There is no :focus filter in jQuery, that is why we can use something like this:
$('input:focus').someFunction();
i have a telerik menu control that can have an <ItemTemplate>.
suppose i have :
<telerik:RadMenuItem Text="Filter" Value="Search" >
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server""/>
</ItemTemplate>
</telerik:RadMenuItem>
how can i dynamically create the textbox itemTemplate in code behind?
I've looked around for a while, but there doesn't seem to be a simple way to do this. jQuery doesn't help the in least, it seems to entirely lack any support for selection or DOM ranges. Something which I hoped would be as simple as $.selection.filter('img') seems to only be doable with dozens of lines of code dealing with manually enumerating elements in ranges and browser implementation inconsistencies (though ierange helps here). Any other shortcuts?
Hi,
i have this page.
login: [email protected] password: m
You can see two selects in the filter for which i have this rule in gente.css:
td.select label{
margin-left:12px;
}
The problem: the rule is applied but doesn't appear in the Style tab of Firebug.
Any idea?
Regards
Javi
I am using Groovy in a Java Swing application as part of my plan to force-feed myself dynamic languages until I like them (which is happening, partly).
My stack traces are filled with Groovy stuff like
org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor
is there a way to get Eclipse to remove all of that codehaus stuff (filter stack traces, basically)?
Edit: I can do this from the command-line with grep (well, not yet) so it's not so bad, but inside of Eclipse would be great too.
I have a Perl script to open this page http://svejo.net/popular/all/new/ and filter the names of the posts but except headers everything seems encrypted. Nothing can be read. When I open the same page in a browser everything looks fine including the source code. How is it possible to encrypt a page for a script and not for a browser? My Perl script sends the same headers as my browser (Google Chrome).
Hi Guys,
Is there a built-in functionalities in solr/lucene to filter the results if they fall below a certain score threshold? Let's say if I provide a score threshold of .2, then all documents with score less than .2 will be removed from my results. My intuition is that this is possible by updating/customizing solr or lucene.
Could you point me to right direction on how to do this?
Thanks in advance!
My sql query gives the columns:
product_id (which is an integer)
pnl (which is float - can be negative)
I get more than 100 rows.
I want to filter out the top 40 rows based on abs(pnl).
But the results should be ordered by pnl column only and not by abs(pnl).
I want to do this for MSSQL 2005.
Is there a way to do this?
I use apache common lang to unescape a block of html text which contains ,
I want to filter out blocks that contains only whitespaces.
But I can't test the as a whitespace. It's not in the normal whitespace list(http://en.wikipedia.org/wiki/Whitespace_character), and I try to print its Hex form by calling Character.getNumericValue which return -1.
  should be a whitespace,isn't? But How can I test it?
I have a jQueryUI slider on my website that deals with price range.
I have a products table in mysql that has various entries.
I am using the slider to filter the results, but I need to set the minimum and maximum prices from the records in my database.
Should I just generate (with php) hidden fields in my html that contain the minimum and maximum and then use jQuery to obtain them? Or is there a better way of achieving this, maybe using AJAX?
Thanks
I have a model that looks like this:
class Client(models.Model):
name = models.CharField(max_length=100, primary_key=True)
user = models.ForeignKey(User)
class Contract(models.Model):
title = models.CharField(max_length=100, primary_key=True)
start_date = models.DateField()
end_date = models.DateField()
description = models.TextField()
client = models.ForeignKey(Client)
user = models.ForeignKey(User)
How can i configure a django form so that only clients associated with that user show in the field in the form?
My initial thought was this in my forms.py:
client = forms.ModelChoiceField(queryset=Client.objects.filter(user__username = User.username))
But it didn't work. So how else would I go about it?
I have a gridview (Edit and Delete enabled) that shows a table. A Text Box and A Button. When I type something in the textbox and click the button, the button runs the datasource.filterexpression and filters out the rows.
The question whenever I click on the edit button after the filter has been applied The grid auto resets back to the original table? How can I solve this?
I have added a 'cancelled' field to my model, is there a way to modify the model default query to something like cancelled=False ? without having to modify all my filter/exclude queries ?
What's the cleanest way of filtering a Python string through an external program? In particular, how do you write the following function?
def filter_through(s, ext_cmd):
# Filters string s through ext_cmd, and returns the result.
# Example usage:
# filter a multiline string through tac to reverse the order.
filter_through("one\ntwo\nthree\n", "tac")
# => returns "three\ntwo\none\n"
Note: the example is only that - I realize there are much better ways of reversing lines in python.
Hi all,
I currently have a JAX-WS Web Service that receives some credentials in the HTTP header. These are used for BASIC authentication.
There is a filter that performs authentication by reading the HTTP headers and checking against the database.
Still, I need the username from within the Web Service in order to perform other service logic related stuff. Is there a way of accessing the HTTP headers from within the Web Service?
Thanks.
Here's the setup. I have web site which is essentially a simple CMS. Here is the routes file:
map.connect ':url', :controller => :pages, :action => :show
map.root :controller => :pages, :action => :show, :url => "/"
The page controller is thus:
class PagesController < ApplicationController
before_filter :verify_access, :except => [:show]
# Cache show action if we are not logged in.
caches_action :show, :layout => false, :unless => Proc.new { |controller| controller.logged_in? }
def update
@page = Page.find(params[:id])
respond_to do |format|
expire_action :action => :show, :url => @page.url
So when a visitor hits "/" it maps to :controller = "pages, :action = "show, :url = "/". This generates a cached version on first try, then returns the appropriate result there after. The log files show:
Processing PagesController#show (for 127.0.0.1 at 2009-08-02 14:15:01) [GET]
Parameters: {"action"=>"show", "url"=>"/", "controller"=>"pages"}
Cached fragment hit: views/out.local// (0.1ms)
Rendering template within layouts/application
Filter chain halted as [#<ActionController::Filters::AroundFilter:0x23eb03c @identifier=nil, @method=#<Proc:0x01904858@/Library/Ruby/Gems/1.8/gems/actionpack-2.3.3/lib/action_controller/caching/actions.rb:64>, @kind=:filter, @options={:only=>#<Set: {"show"}>, :if=>nil, :unless=>#<Proc:0x025137ac@/Users/askegg/Sites/out/app/controllers/pages_controller.rb:6>}>] did_not_yield.
Completed in 2ms (View: 1, DB: 0) | 200 OK [http://out.local/]
OK - all good so far. When I update the page, it should expire the cache (see above). The logs show:
Page Load (0.2ms) SELECT * FROM "pages" WHERE ("pages"."id" = 3)
Page Load (0.1ms) SELECT "pages".id FROM "pages" WHERE ("pages"."url" = '/' AND "pages".domain_id = 1 AND "pages".id <> 3) LIMIT 1
Expired fragment: views/out.local/index (0.1ms)
Redirected to http://out.local/pages/3
Completed in 9ms (DB: 0) | 302 Found [http://out.local/pages/3]
See the problem? Rails is clearing the cache named "index", but it sets it as "/". Naturally this results in the cache NOT being cleared, so visitors are now seeing the old version.
hi i m using Linq & C# and i want to filter my data as this syntax in Sql
Syntax in sql is
I hav one table name Customer in which name is field
'Select name from customer where name like 'C%''
can u help to solve this code in Linq
I run a site where users can upload content that is displayed in a gallery where other users can sort and filter that content. While implementing RSS feeds, I was wondering how common it was for an RSS feed to display items in an order that's different from chronological. For example, displaying content by Most Views first. This could be useful for someone wanting to keep tabs on trending content. How do RSS readers handle this, since most RSS feeds are ordered chronologically?
I am interested in activating another application's activity. I know from reading the Android SDK that it's probably better to do this with an implicit intent. However, this activity doesn't reside in an application I own, so I don't know the action and category and data flags on the intent-filter.
How can I examine an Android applications metadata like the activity classes and the intent-filters for those activities (if declared in the manifest)?
Thanks!
I have a Perl script to open this page http://svejo.net/popular/all/new/ and filter the names of the posts but except headers everything seems encrypted. Nothing can be read. When I open the same page in a browser everything looks fine including the source code. How is it possible to encrypt a page for a script and not for a browser? My Perl script sends the same headers as my browser (Google Chrome).
Hi,
I want to write only a specific portion of a .avi file in the output .avi file .For this I follow Source Filter -Avi mux-File Writer.I try to use IMediaSeeking on the Mux to set the specific start and stop times using Set Positions but it returns E_NOTIMPL.
I also try to query the graph builder for IMediaSeeking and try to set the start and stop positions with no success.Can someone help?
I found a quite large list of available libraries on Node.JS wiki but I'm not sure which of those are more mature and provide better performance. Basically I want to do the following:
load some images to a server from external sources
put them onto one big canvas
crop and mask them a bit
apply a filter or two
Resize the final image and give a link to it
Big plus if the node package works on both Linux and Windows.