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 ?
I'm trying to get the video element in a queryset but am having trouble retrieving it.
user_channel = Everything.objects.filter(profile = request.user, playlist = 'Channel')
print user_channel[0] #returns the first result without error
print user_channel[0]['video'] #returns error
Models.py:
class Everything(models.Model):
profile = models.ForeignKey(User)
playlist = models.CharField('Playlist', max_length = 2000, null=True, blank=True)
platform = models.CharField('Platform', max_length = 2000, null=True, blank=True)
video = models.CharField('VideoID', max_length = 2000, null=True, blank=True)
video_title = models.CharField('Title of Video', max_length = 2000, null=True, blank=True)
def __unicode__(self):
return u'%s %s %s %s %s' % (self.profile, self.playlist, self.platform, self.video, self.video_title)
I have poured over every example that I can find and I have gone through the official documentation from google. All I am trying to do is create a toast notification from a button click on a widget.
I can get the widget (and button) to appear but I can't get my intent to fire. I have seen several examples that show doing this different ways but I just can't get it to work. I haven't felt this helpless with coding in a long time and I'm starting to feel dumb.
This is what I have so far:
public class simpleclick extends AppWidgetProvider {
/** Called when the activity is first created. */
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
final int N = appWidgetIds.length;
Toast.makeText(context, "doing on update", Toast.LENGTH_SHORT).show();
for (int i=0; i<N; i++) {
int appWidgetId = appWidgetIds[i];
Intent intent = new Intent(context, simpleclick.class);
intent.setAction("ham");
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.main);
views.setOnClickPendingIntent(R.id.Timm, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
//@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Toast.makeText(context, "action is: " + intent.getAction(), Toast.LENGTH_SHORT).show();
super.onReceive(context, intent);
}
}
My manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tblabs.simpleclick"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<receiver android:name="simpleclick">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/simpleclick" />
</receiver>
</application>
<uses-sdk android:minSdkVersion="5" />
</manifest>
I would appreciate some help!
Thanks,
Wendy
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 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
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!
Using MATLAB I filtered a very noisy m x n array with a low-pass Gaussian filter, cleaned it up pretty well but still not well enough to analyze my data. What would the next step be? I'm thinking that signal enhancement, but am not sure how to go about this.
Hello,
So I have the following:
var box = $(".MyCheckBox");
if (box[0].checked)
{
// Do something
}
else
{
// Do something else
}
Is there a better way of doing this using filters or something?
I know I can go:
$(".MyCheckBox")
.filter(function(index) {
return this.checked;
})
.each(function() {
// do something
});
But I need to do something in the else statement... easier way of doing this? Thanks!
I am looking for more complete sample code on how TeeFilter of Logback can be used to log HTTP messages.
I am trying to add this support to my Spring 3 (MVC)/Hibernate 3/Annotations Maven2 project. I have the config and xml files but I need to know where and how I can trigger this Filter to do the job for me in the Spring MVC framework.
Any help will be greatly appreciated.
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 have some DropDownList controls where the list is very large, so I would like to have a means for the user to filter the list, either based on other fields, e.g. region, or on the first letters typed in a textbox. How can I achieve this in ASP.NET? Is the an open source control out there that will help me?
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).
I recently posted about the Play store not letting me publish my app without a minSdkVersion, but whenever I set it to anything above "1" my app just doesn't work (minSdkVersion breaking program).
So this guy suggested to just set my minSdkVersion to 1, which worked. But now when I submitted my app even though the developer site says:
API level: 1-16+
Supported screens: normal-xlarge
OpenGL textures: all
But the app only shows it supports Android under 4.x, I developed it on my 4.0.4 device. I tried searching around and I found that some people have problems with services messing up the phones it supports, so I deleted all of my services, because I don't really need any for this version of the app to submit. And it still didn't work. So I don't know what else to do, here is my AndroidManifest.xml if it helps... I've been trying to figure out why my application isn't working for a week now, still nothing. I have tried setting a targetSdkVersion to something like 14, my application still breaks. I cleaned out my code, taking everything out of the already short, 200 lines, application, and it still isn't working. Is there something I can't use in an android application 4.0 that I am using in my application? or is it just my AndroidManifest? Thank you so much!
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.unparalleledsoftware.app.list"
android:versionCode="5"
android:versionName="2.02" >
<uses-sdk
android:minSdkVersion="1" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I should note,I am using the Theme.Holo.Light, but even if I change it to DeviceDefault it doesn't work.
Edit:
I googled the app on my friends Samsung Galaxy S3 (it didn't show up in the Play Store on his phone), when I installed by googling the app and hitting the "install" button on google and it opened in the Google Play store and was able to install. When I did the same on my phone, Galaxy Note, it opened in the Google Play Store, but then said "Not compatible." Why? They are both on the same version of OS. Why is mine not compatible, nor the One X compatible, but the Samsung Galaxy S3 worked...?
Edit: I get these errors/problems when compiling with a targetSdkVersion, http://pastebin.com/mxgWNLdM
I want to write a function which takes a list and constructs a subset of that list of a certain length based on the output of a function.
If I were simply interested in the first 50 elements of the sorted list xs, then I would use fst (splitAt 50 (sort xs)).
However, the problem is that elements in my list rely on other elements in the same list. If I choose element p, then I MUST also choose elements q and r, even if they are not in the first 50 elements of my list. I am using a function finderFunc which takes an element a from the list xs and returns a list with the element a and all of its required elements. finderFunc works fine. Now, the challenge is to write a function which builds a list whose total length is 50 based on multiple outputs of finderFunc.
Here is my attempt at this:
finish :: [a] -> [a] -> [a]
--This is the base case, which adds nothing to the final list
finish [] fs = []
--The function is recursive, so the fs variable is necessary so that finish
-- can forward the incomplete list to itself.
finish ps fs
-- If the final list fs is too small, add elements to it
| length fs < 50 && length (fs ++ newrs) <= 50 = fs ++ finish newps newrs
-- If the length is met, then add nothing to the list and quit
| length fs >= 50 = finish [] fs
-- These guard statements are currently lacking, not the main problem
| otherwise = finish [] fs
where
--Sort the candidate list
sortedps = sort ps
--(finderFunc a) returns a list of type [a] containing a and all the
-- elements which are required to go with it. This is the interesting
-- bit. rs is also a subset of the candidate list ps.
rs = finderFunc (head sortedps)
--Remove those elements which are already in the final list, because
-- there can be overlap
newrs = filter (`notElem` fs) rs
--Remove the elements we will add to the list from the new list
-- of candidates
newps = filter (`notElem` rs) ps
I realize that the above if statements will, in some cases, not give me a list of exactly 50 elements. This is not the main problem, right now. The problem is that my function finish does not work at all as I would expect it to. Not only does it produce duplicate elements in the output list, but it sometimes goes far above the total number of elements I want to have in the list.
The way this is written, I usually call it with an empty list, such as: finish xs [], so that the list it builds on starts as an empty list.
I have an entity with many-to-one mapping. (Product 1-* Regions, unidirectional association)
What is the best way to store index of such relation?
So it can be easily used to filter search query .
Simple example: we have string "Some sample string Of Text". And I want to filter out all stop words (i.e. "some" and "of") but I don't want to change letter case of other words which should be retained.
If letter case was unimportant I would do this:
str.toLowerCase().replaceAll ("a|the|of|some|any", "");
Is there an "ignore case" solution with regular expressions in java?
How do I find the name of the namespace or module 'Foo' in the filter below?
class ApplicationController < ActionController::Base
def get_module_name
@module_name = ???
end
end
class Foo::BarController < ApplicationController
before_filter :get_module_name
end
Yet another newbie question..
Let's say I have an user table in declarative mode:
class User(Base):
__tablename__ = 'user'
id = Column(u'id', Integer(), primary_key=True)
name = Column(u'name', String(50))
When I have a list of users identifiers, I fetch them from db with:
user_ids = [1, 2, 3, 4, 5]
users = Session.query(User).filter(User.id.in_(user_ids)).all()
I dislike using in_ because I think I learned it has bad performance on indexed fields
(is that true/false?).
Anyway, is there a better way doing that query?
Thanks!
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?
Hi,
I've a database that has a name field. (i.e Firstname M. Lastname or just Firstname Lastname).
Trying to filter by lastname.
How can I do a query to find the last space?
Something like
select * from person where name like "% a%" (but the space is the last space)
Thanks,
Tee
I'm looking to rewrite my git repo to use a new branching model I came across:
http://nvie.com/git-model
But right now all my history lives in the master branch. I'd like to rewrite it (possible using git-filter-branch?) So that all that history is in a branch called development now.
Is this possible? It's definitely beyond my limited git skills.
how should I list a form controls in a Combobox of the same form(like VS designer does)?
I tried:
cboObjectSelection.DataSource = Me.Controls
but this does not work.
Is there a possibility to filter(customize) this list?
I want to overide a style thats in a stylesheet on another server. However, I dodnt want to enter new values, I just want to cancel out that style somehow. Is that possible? The competing style is overiding some of my other styles and I just want to basically filter the remote style out.
Task: On click of li navigation filter show and hide content with a transitional fadein fade out.
Problem I'm just guessing and checking on where to place this fadein//fadeout transition. Furthermore, I feel like my code is too inefficiency because I'm using 4 conditional statements. Would stack lead me in creating a solution to improve the overall logic of this script so I can just make a pretty transition :c?
LIVE CODE
jQuery Script
$(document).ready(function () {
//attach a single click listener on li elements
$('li.navCenter').on('click', function () {
// get the id of the clicked li
var id = $(this).attr('id');
// match current id with string check then apply filter
if (id == 'printInteract') {
//reset all the boxes for muliple clicks
$(".box").find('.video, .print, .web').closest('.box').show();
$(".box").find('.web, .video').closest('.box').hide();
$(".box").find('.print').show();
}
if (id == 'webInteract') {
$(".box").find('.video, .print, .web').closest('.box').show();
$(".box").find('.print, .video').closest('.box').hide();
$(".box").find('.web').show();
}
if (id == 'videoInteract') {
$(".box").find('.video, .print, .web').closest('.box').show();
$(".box").find('.print, .web').closest('.box').hide()
$(".box").find('.video').show();
}
if (id == 'allInteract') {
$(".box").find('.video, .print, .web').closest('.box').show();
}
});
HTML Selected
<nav>
<ul class="navSpaces">
<li id="allInteract" class="navCenter">
<a id="activeAll" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/logo30px.png" /><h3>all</h3></div></a>
</li>
<li id="printInteract" class="navCenter">
<a id="activePrint" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/print.gif" /><h3>print</h3></div></a>
</li>
<li id="videoInteract" class="navCenter">
<a id="activeVideo" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/video.gif" /><h3>video</h3></div></a>
</li>
<li id="webInteract" class="navCenter">
<a id="activeWeb" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/web.gif" /><h3>web</h3></div></a>
</li>
</ul>
ps. Sorry for the newbie question