Thursday, 3 October 2013

How to pass in a method as an expression using attributes?

How to pass in a method as an expression using attributes?

I want to decorate by the attribute a test method. This attribute should
know about what test is considered to be previous with regard to the
attributed method. Here is an exampel:
private void
DestinationChoiceViewLoaded_AllTpmFeaturesAreEnabled_UIElementsAreSetUpProperly()
{
var vut = new DestinationChoiceViewUIWrapper();
UIControlAssert.Clickable(vut.GetNextPageButton());
UIControlAssert.Clickable(vut.GetPreviousPageButton());
}
[PreviousTestInOrder()]
public void Run_DestinationChoiceView_Tests() {
var vut = new DestinationChoiceViewUIWrapper();
UIControlAssert.Clickable(vut.GetNextPageButton());
UIControlAssert.Clickable(vut.GetPreviousPageButton());
}
Somehow, I want to pass in
DestinationChoiceViewLoaded_AllTpmFeaturesAreEnabled_UIElementsAreSetUpProperly
to the attribute constructor.
I tried:
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited
= false)]
public class PreviousTestInOrderAttribute : Attribute
{
public string MethodName { get; private set; }
public PreviousTestInOrderAttribute(Expression<Action>
memberExpression) {
MethodName = GetMemberName(memberExpression);
}
public static string GetMemberName(Expression<Action> memberExpression) {
MemberExpression expressionBody = (MemberExpression)
memberExpression.Body;
return expressionBody.Member.Name;
}
}
But if I do

[PreviousTestInOrder(() =>
DestinationChoiceViewLoaded_AllTpmFeaturesAreEnabled_UIElementsAreSetUpProperly)]
it won't compile :(

Wednesday, 2 October 2013

urllib2 error 'Not found on Accelerator'

urllib2 error 'Not found on Accelerator'

I have a python program that periodically checks the weather from
weather.yahooapis.com, but it always throws the error: urllib.HTTPError:
HTTP Error 404: Not Found on Accelerator. I have tried on two different
computers with no luck, as well as changing my DNS settings. I continue to
get the error. Here is my code:
#!/usr/bin/python
import time
#from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
from xml.dom import minidom
import urllib2
#towns, as woeids
towns = [2365345,2366030,2452373]
val = 1
while val == 1:
time.sleep(2)
for i in towns:
mdata =
urllib2.urlopen('http://206.190.43.214/forecastrss?w='+str(i)+'&u=f')
sdata = minidom.parseString(mdata)
atm = sdata.getElementsByTagName('yweather:atmosphere')[0]
current = sdata.getElementsByTagName('yweather:condition')[0]
humid = atm.attributes['humidity'].value
tempf = current.attributes['temp'].value
print(tempf)
time.sleep(8)
I can successfully access the output of the API through a web browser on
the same computers that give me the error.

NullReferenceExeption in C# when the container is initialized

NullReferenceExeption in C# when the container is initialized

In the code listed below, I get a "NullReferenceExeption" with the error :
"Object reference not set to an instance of an object". I am completely
new to C#, but guess the error is related to the inheritance and/or the
template definitions. The list gets initialized, and when debugging I can
confirm that the list does not point to NULL. I can't figure out how to do
this in another way - Appreciate the help! (Sorry about the confusing
class names / structure) EDIT : The exeption happens here :
this.localSMT.doSomething(base.list);
public class VTEST<V>
{
public List<V> list;
public LocalSMT<V> localSMT;
public VTEST()
{
list = new List<V>();
}
}
public class VTEST_FSUB<V> : VTEST<V>
{
public VTEST_FSUB()
{
do_virtual();
}
public void do_virtual()
{
this.localSMT.doSomething(base.list);
}
}
public class VTEST_RUN : VTEST_FSUB<int>
{
public VTEST_RUN()
{
localSMT = new VTEST_SUB();
}
}
public class LocalSMT<V>
{
public LocalSMT() { }
public virtual void doSomething(List<V> value) { }
}
public class VTEST_SUB : LocalSMT<int>
{
public VTEST_SUB(){}
public override void doSomething(List<int> value) {
System.Console.WriteLine("VTEST_SUB VIRTUAL");
}
}
class Program
{
Program() {}
static void Main(string[] args)
{
VTEST_RUN run = new VTEST_RUN();
}
}

iOS 7 no longer working with XCode

iOS 7 no longer working with XCode

I have XCode version 4.6.3 and have just recently upgraded the OS on my
iPhone 4 to iOS 7. When I try to run my code on my device I get the
following error:
**Xcode cannot run using the selected device.**
No provisioned iOS devices are available with a compatible iOS version.
Connect an iOS device with a recent enough version of iOS to run your
application or choose an iOS simulator as the destination.
In Organizer I'm seeing the following message:
The version of iOS on "My Phone's Name" is not supported by this
installation of the iOS SDK. Please restore the device to a version of the
OS listed below, or update to the latest version of the iOS SDK; which is
available here.
The here link just prompts me to login to Member Center and doesn't drop
me off anywhere about the latest SDK.
My deployment target is iOS 6.1, I don't want to raise that to 7.0 as the
majority of our users are on pre iOS 7. I am running OS X version 10.8.3,
can I upgrade my SDK? Do I have to? How can I make it so my SDK is
compatible with iOS 7 and pre iOS 7 devices?

Software downloader downloading dozens of mb (almost) every day

Software downloader downloading dozens of mb (almost) every day

Why does ubuntu's software updater download around 80 mb (almost) every
day? Does it simply replace the original content constantly? It is not
always downloading for the same application, but it still strikes me as
too much.

Tuesday, 1 October 2013

How to find the range of f(S) ?

How to find the range of f(S) ?

Let S={z:1¡ÜIm(z)¡Ü2}. Determine f(S) if f:S¡úC is defined by
f(z)=(z+1)/(z&#8722;1).

conflict between two model rails

conflict between two model rails

I am having two model post and product
This is my post controller
before_action :seo_url,only: [:show]
def product_list
if params[:product_id] == 1
@products = Product.All
end
respond_to do |format|
format.json { render json: @products.id }
end
end
private
def seo_url
@post = Post.friendly.find params[:id]
end
Here is my ajax call
$.ajax({
type: "GET",
url: '/posts/product_list.json',
data: {product_id: 1},
dataType: 'json'
});
My console throwing something like this. I cant understand what is
happening can anyone help
Parameters: {"product_id"=>"1", "_"=>"1380659219433", "id"=>"product_list"}
Post Load (0.9ms) SELECT "posts".* FROM "posts" WHERE "posts"."slug" =
'product_list' ORDER BY "posts"."id" ASC LIMIT 1
Completed 404 Not Found in 5ms
ActiveRecord::RecordNotFound (ActiveRecord::RecordNotFound):
app/controllers/posts_controller.rb:85:in `seo_url'

People are countable or uncountable noun=?iso-8859-1?Q?=3F_=96_ell.stackexchange.com?=

People are countable or uncountable noun? – ell.stackexchange.com

I saw these sentences in the internet. There are three people here. A few
people didn't enjoy the play. Now I'm not sure if "people" and other
collective nouns like team, family and ...

Place emphasis that "thanks/me too" is not permitted anywhere – meta.stackoverflow.com

Place emphasis that "thanks/me too" is not permitted anywhere –
meta.stackoverflow.com

The protected questions text says the following: As it stands currently,
it sounds as though it's been protected only on a case by case basis, and
that "thanks" or "me too" posts by new users is …