If I want to create a .NET object in the powershell I write something like the following:
[System.Reflection.Assembly]::LoadWithPartialName("System.Xml") | out-null"
$doc = new-object -typename System.Xml.XmlDocument"
If I want to call a static .Net method I use a command similar to the following line:
$path = [System.String]::Format...
I'm working in two different Oracle schemas on two different instances of Oracle. I've defined several types and type collections to transfer data between these schemas. The problem I'm running into is that even though the type have exactly the same definitions (same scripts used to create both sets in the schemas) Oracle sees them as ...
The following event can possibly get called hundreds of times a frame.
public bool OnCollision(Body body1, Body body2)
{
if(body2.Tag is Dog)
((Dog)body2.Tag).Bark();
}
I understand that using "is" causes a cast to be made and then when i want to do something with it, cast it a second time. Is there a more efficient way to chec...
I need to know if a variable in Python is a string or a dict. Is there anything wrong with the following code?
if type(x) == type(str()):
do_something_with_a_string(x)
elif type(x) == type(dict()):
do_somethting_with_a_dict(x)
else:
raise ValueError
Update: I accepted avisser's answer (though I will change my mind if some...
In Haskell, is there a way to restrict a monad M a so that a satisfy a type class constraint?
I am translating the probabilistic modeling example from F# to Haskell. However, in Haskell, I omitted support because it would change data Distribution a to data (Ord a) => Distribution a. With this change, I get the following error:
...proba...
In a system level programming language like C, C++ or D, what is the best type/encoding for storing latitude and longitude?
The options I see are:
IEEE-754 FP as degrees or radians
degrees or radians stored as a fixed point value in an 32 or 64 bit int
mapping of an integer range to the degree range: -> deg = (360/2^32)*val
degrees, m...
How can I initialize a list containing generic objects whose types can be different?
For example, I have the following:
this.Wheres = new List<Where<>>();
As you know, <> is not valid syntax. However, sometimes the type passed to Where will be a string and sometimes it will be DateTime, etc. I tried using object as the initialized ty...
What are general guidelines on when user-defined implicit conversion could, should, or should not be defined?
I mean things like, for example, "an implicit conversion should never lose information", "an implicit conversion should never throw exceptions", or "an implicit conversion should never instantiate new objects". I am pretty sure ...
I have read posts like these:
What is a metaclass in Python?
What are your (concrete) use-cases for metaclasses in Python?
Python's Super is nifty, but you can't use it
but somehow I got confused, many confusions like
when and why i would have to do something like this
#refer link1
return super(MyType, cls).__new__(cls, name, bas...
I encountered this term "Hindley-Milner" which I'm not sure if grasp what it means. I read Steve Yegge's "Dynamic Languages Strike Back" and "The Pinocchio Problem" and Daniel Spiewak's "What is Hindley-Milner? (and why is it cool?)". But there is no single entry for this term in wikipedia where usually offers me a concise explanation.
...
i am using movable type 4.23 (publishing system) and have been testing my site on a PC and discovered that internet explorer (IE) browsers are unable to view my site due to a conflict in the javascript of the signin widget (initially i thought it was in the mt.js file).
i receive this error: "Error 80004004"...as well as in the Javascri...
I want to see the type of a variabe whether it is unsigned 32 bit,signed 16 bit etc.
How to view...
...
I have a generic Callback object which provides a (primitive) callback capability for Java, in the absence of closures. The Callback object contains a Method, and returns the parameter and return types for the method via a couple of accessor methods that just delegate to the equivalent methods in Method.
I am trying to validate that a ...
Specifically, with a SortedMap<Vector<String>, int> I get "dimensions expected after this (int) token." Help!
...
Is there a standards-complaint method to represent a byte in ANSI (C89/90) C? I know that, most often, a char happens to be a byte, but my understanding is that this is not guaranteed to be the case. Also, there is stdint.h in the C99 standard, but what was used before C99?
I'm curious about both 8 bits specifically, and a "byte" (size...
Basically I want to do this:
public interface A {
void a();
}
public interface B {
void b();
}
public class SomeClass {
public SomeClass(<A&B> e) { // Note the type here
e.a();
e.b();
}
}
What I did on the commented line is obviously illegal. I know I can just require the passed object to implement inte...
I was expecting to find that section within "System.Web.Configuration" namespace just like other Web.config sections
Under what namespace does "location" reside and what is the type of the section?
...
I need to declare the query variable outside the switch statement that way I would only have one variable that would handle different result of the LINQ Query. Please see the code below. Problem here is that I cannot infer a variable without initializing it
var query;
Switch(filter)
{
case 1:
var query = from c in Customers
...
I have build myself a generic collection class which is defined like this.
public class StatisticItemHits<T>{...}
This class can be used with int and string values only. However this
public class StatisticItemHits<T> where T : string, int {...}
Won't compile. what am I doing wrong?
...
The idea is to define a base class that can invoke methods defined in derrived classes, but at creation time I want to ensure, that such methods are defined exactly according to the requirements, which is that the methods take only one argument, a HashMap<String String>.
So far I was able with the following code to check that the method...