List Class in Python-Twitter - python-twitter

Despite a day's searching and trying I cannot get around the List Class of the python-twitter module.
The aim of the game is very simple, I want to retrieve all the followers (my students) I have previously grouped into a Twitter list called MyStudents.
I am stuck very early in the process as I am not even sure how to get an instance of the list class (I decalre an instance of the Api class without any problem):
The following
`list=twitter.List()`
seems to send back an empty set. And so do
`list=twitter.List(name='MyStudents')`
and the rather desperate
list=twitter.List('MyStudents')
Could anyone point me in the right direction ?
Thanks in advance

Related

How to add an element in a table that contains multiple instances of objects from another table in Spring Boot?

I'm sure there is a simple solution to my problem but I'm having trouble finding it online so I would be very grateful if someone could point me in the right direction.
So I have a Spring Boot application that uses an external database. I have a table and class called Ingredient that contains the various ingredients. That class has all the necessary methods (PUT, POST, DELETE, GET) and they work as intended.
Now I need to implement another class called Food and every object of type Food should be initiated with a name and a list of Ingredients.
I don't know how to implement it. I made the class Food and I defined a #ManyToMany relationship between the two classes/tables but I don't know how to implement the POST method for the Food.
I tried googling but I'm having trouble wording my problem.

Simple friendship in Parse

I have asked this question in parse.com google group, but didn't get an answer. So technically this is an x-post.
I want to make a simple friendship class in parse between two users(not parse users, I have a profile table with user objects in it). Since there is no examples in JS sdk guide of parse, I am just trying to make something that works. So I've decided to make a friendship class in parse, and have pointer for each friendship:
pointer user1 pointer user2
But with this method I've encountered some issues like when trying to get a persons friendlist I need to make 2 different queries, also when adding a friendship need to double check to avoid duplicating etc.
So what I am trying to achieve is a simple friendship class, where I can easily determine if 2 users are friends, get users friendlist, avoid duplicating in the db.

Having trouble navigating Magento documentation

I am brand new to Magento and the documentation, primarily the phpDocs, are difficult to navigate. For example,
$attributeSet = Mage::getModel('eav/entity_attribute_set')->load($id);
In the php doc for Class Mage_Eav_Model_Entity_Attribute_Set there is no mention of the method getAttributeSetName() either in inherited methods or otherwise and yet this works.
$attributeSet = Mage::getModel('eav/entity_attribute_set')->load($id);
echo $attributeSet->getAttributeSetName();
So I suppose I have several questions.
Can someone explain to me why the documentation is this way?
Where I can find the mysterious getAttributeSetName() method in the phpDocs?
My theory is that there is some inheritance or a design pattern implementation going on that I'm not understanding, maybe someone can shed some light on this for me.
If you really want to fry your brain, take a look at the source code for Mage_Eav_Model_Entity_Attribute_Set and follow the inheritance chain all the way back. You won't find a getAttributeSetName method defined anywhere.
All Magento objects that inherit from Varien_Object can have arbitrary data members set on them. Try this.
$attributeSet = Mage::getModel('eav/entity_attribute_set')->load($id);
$attributeSet->setFooBazBar('Value');
var_dump($attributeSet->getFooBazBar());
var_dump($attributeSet->getData('foo_baz_bar'));
var_dump($attributeSet->setData('foo_baz_bar','New Value'));
var_dump($attributeSet->getFooBazBar());
You can also get all the data members by using
var_dump($attributeSet->getData());
but be careful dumping these, because if there's a data object that has a circular reference and you're not using something like xDebug, then PHP will have a fit trying to display the object.
Magento stores data properties in a special _data array property. You can get/set values in this array with getData and setData. Magento also has implemented magic getting and setter methods, so when you say something like
$object->getFooBazBar();
The method getFooBazBar is transformed into the data property foo_baz_bar. and then getData is called using this property. It's a little tricky to get your head around, but once you get it you'll start to see how much time you can save using this pattern.
One side effect of this is, of course, it's impossible to infer what data properties any object might have by looking at it's class file, so there's no phpDocs for these methods.

How to save a QStandardItemModel?

I'm currently writing an application that plays podcasts. I'm representing all the feeds and the episodes within them as QStandardItem objects within a QStandardItemModel. Right now, I don't have a way to save this model--when the application closes, the feed model goes up in smoke. I looked at using QSettings, but that only works for datatypes that fall under QVariant.
Looking at this post gave me some hope, but I think I'm doing something wrong. I've got the following code in the constructor for my application.
//Expand QVatiant to use QStandardItemModel
qRegisterMetaType<QStandardItemModel>("QStandardItemModel");
That, however, gives me this error at compile time.
/ [...] QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtGui.framework/Versions/4/Headers/qstandarditemmodel.h:424: error: 'QStandardItemModel::QStandardItemModel(const QStandardItemModel&)' is private
Ah. That reminds me of this caveat from the Qt documentation for QMetaType, here.
Any class or struct that has a public default constructor, a public copy constructor and a public destructor can be registered.
So, where do I go from here? Qt is behaving exactly as it should, so this approach won't work. I'm thinking of saving off the model as an xml file, but that seems like a ton of effort. This seems like a pretty common problem--I just don't know where to look for the answer.
Here's the best solution I could come up with: Create a method that saves the model into an XML document, and call it whenever I change the model (e.g. add or remove a podcast). I don't have the actual source code on hand, but since there's no real easy way to save the data structure wholesale, this is the best solution.

Ruby, Candy and SQL-like mongo stuff

So Candy is a really simple library for interacting with Mongo in Ruby.
My poor SQL brain is having a tough time figuring out how I should map out this problem:
There are users, there are things. Each thing was made by one user, but should be accessible to a subset of all users (specified within the thing). Leaving the specification of user out of the way for now, how would I get a list of all things that user X has access to?
class Thing
include Candy::Piece
end
class Things
include Candy::Collection
collects :thing
end
Should I assign the allowed users to a thing like this? (lets just use strings to reference users for now)
t = Thing.new
t.allowed = ['X','Y','Z']
This seems about right to me, which would make me want to do:
Things.find(allowed:'X')
but it's not quite working…
NoMethodError: undefined method ‘call’ for {:allowed=>"X"}:Hash
any ideas?
I'm really sorry I took so long to catch this and respond. This might be too late for your purposes, but:
Candy doesn't implement a find method. This is on purpose: if an object represents a collection, every access is implicitly finding something in that collection. It's the same reason there is no save method. If the mapping is truly transparent, verbs that mean "Do this in the database" shouldn't be necessary.
So to do what you want, you could either just make a new Things object with the scope passed on creation:
x_is_allowed = Things.new(allowed: 'X')
...or you could save a step and do it by class method:
x_is_allowed = Things.allowed('X')
...or you could start with the whole collection and limit it by attribute later:
things = Things.new
x_is_allowed = things.allowed('X')
So... Um. All of those will work. But. I have to warn you that I'm really not happy with the general usability of Candy right now, and of collections and array fields in particular. The biggest problem is accessors: the [] method isn't working like you'd expect, so you end up having to call to_a and refresh and other things that feel sticky and unpleasant.
This needs to be fixed, and I will do so as soon as I finish the driver rewrite (a related project called Crunch). In the short term, Candy is probably best viewed as an experiment for the adventurous, and I can't guarantee it'll save time until the interface is locked down a bit better. I'm sorry about that.

Resources