I have a piece of code:
links
|> Seq.map (fun x -> x.GetAttributeValue ("href", "no url"))
Which I wanted to rewrite to:
links
|> Seq.map (fun x -> (x.GetAttributeValue "href" "no url"))
But the F# compiler doesn't seem to like that. I was under the impression that these two function calls were interchangeable:
f (a, b)
(f a b)
The error that I get is:
The member or object constructor 'GetAttributeValue' taking 2 arguments are not accessible from this code location. All accessible versions of method 'GetAttributeValue' take 2 arguments.
Which seems amusing, as it seems to indicate that it needs what I'm giving it. What am I missing here?
Does anyone understand why Java is missing:
An access specifier which allows access by the class and all subclasses, but NOT by other classes in the same package? (Protected-minus)
An access specifier which allows access by the class, all classes in the same package, AND all classes in any sub-package? (Default-plus)
An access specifier which adds classes in sub-packages to the entities currently allowed access by protected? (Protected-plus)
I wish I had more choices than protected and default. In particular, I'm interested in the Protected-plus option.
Say I want to use a Builder/Factory patterned class to produce an object with many links to other objects. The constructors on the objects are all default, because I want to force you to use the factory class to produce instances, in order to make sure the linking is done correctly. I want to group the factories in a sub-package to keep them all together and distinct from the objects they are instantiating---this just seems like a cleaner package structure to me.
No can do, currently. I have to put the builders in the same package as the objects they are constructing, in order to gain the access to defaults. But separating project.area.objects from project.area.objects.builders would be so nice.
So why is Java lacking these options? And, is there anyway to fake it?
May websites, including professional ones usually have a "W3C Markup Validator" and "W3C CSS Validator." Why do you put them there? Is it just pride or is it justified? If it is more than pride, what justifies them?
I have defined an object in 3D space with position, rotation and scale values (all defined as 3D vectors). It also has upwards and forwards direction vectors. When I rotate the object, I need these direction vectors to rotate with it.
Assuming my up vector is (0, 1, 0) and my forwards vector is (0, 0, 1) at zero rotation, how might I achieve this?
Hey everyone,
I'm writing an android application that maintains a lot of "state" data...some of it I can save in the form of onSaveInstanceState but some of it is just to complex to save in memory.
My problem is that sliding the phone open destroys/recreates the app, and I lose all my application state in the process. The same thing happens with the "back" button, but I overloaded that function on my way. Is there any way to overload the phone opening to prevent it from happening?
Thanks in advance.
def common_elements(list1, list2):
"""
Return a list containing the elements which are in both list1 and list2
>>> common_elements([1,2,3,4,5,6], [3,5,7,9])
[3, 5]
>>> common_elements(['this','this','n','that'],['this','not','that','that'])
['this', 'that']
"""
for element in list1:
if element in list2:
return list(element)
Got that so far, but can't seem to get it to work! Thanks
I would like to safely be able to simulate open with O_CREAT | O_WRONLY | O_TRUNC | O_NOFOLLOW and O_CREAT | O_WRONLY | O_APPEND | O_NOFOLLOW on systems that do not support O_NOFOLLOW. I can somewhat achieve what I am asking for with:
struct stat lst;
if (lstat(filename, &lst) != -1 && S_ISLNK(lst.st_mode)) {
errno = ELOOP;
return -1;
}
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
int fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC | O_NOFOLLOW, mode);
but then I introduce a race condition and possibly a security problem.
I thought about maybe creating a dummy file with only the user being able to write, kind of like touching filename, doing the lstat check, and then using chmod after I finish writing (to correct the file mode bits), but I could be overlooking something major (e.g. if the file at filename exists, is not a regular file, or is already a symbolic link).
What do you think?
This is a wrapper for an API I'm working on, am I doing it sort of right? I'm not particularly fond of all the repeating code in the constructor, if someone can show me if I can reduce that it would be very helpful!
public class WebWizForumVersion
{
// Properties of returned data
public string Software { get; private set; }
public string Version { get; private set; }
public string APIVersion { get; private set; }
public string Copyright { get; private set; }
public string BoardName { get; private set; }
public string URL { get; private set; }
public string Email { get; private set; }
public string Database { get; private set; }
public string InstallationID { get; private set; }
public bool NewsPad { get; private set; }
public string NewsPadURL { get; private set; }
public WebWizForumVersion(XmlReader Data)
{
try
{
Data.ReadToFollowing("Software");
this.Software = Data.ReadElementContentAsString();
Data.ReadToFollowing("Version");
this.Version = Data.ReadElementContentAsString();
Data.ReadToFollowing("ApiVersion");
this.APIVersion = Data.ReadElementContentAsString();
Data.ReadToFollowing("Copyright");
this.Copyright = Data.ReadElementContentAsString();
Data.ReadToFollowing("BoardName");
this.BoardName = Data.ReadElementContentAsString();
Data.ReadToFollowing("URL");
this.URL = Data.ReadElementContentAsString();
Data.ReadToFollowing("Email");
this.Email = Data.ReadElementContentAsString();
Data.ReadToFollowing("Database");
this.Database = Data.ReadElementContentAsString();
Data.ReadToFollowing("InstallID");
this.InstallationID = Data.ReadElementContentAsString();
Data.ReadToFollowing("NewsPad");
this.NewsPad = bool.Parse(Data.ReadElementContentAsString());
Data.ReadToFollowing("NewsPadURL");
this.NewsPadURL = Data.ReadElementContentAsString();
}
catch (Exception e)
{
}
}
}
Hello SO;
I've been fighting with this problem all day and am just about at my wit's end.
I have an XML file in which certain portions of data are stored as escaped text but are themselves well-formed XML. I want to convert the whole hierarchy in this text node to a node-set and extract the data therein. No combination of variables and functions I can think of works.
The way I'd expect it to work would be:
<xsl:variable name="a" select="InnerXML">
<xsl:for-each select="exsl:node-set($a)/*">
'do something
</xsl:for-each>
The input element InnerXML contains text of the form
<root><element a>text</element a><element b><element c/><element d>text</element d></element b></root>
but that doesn't really matter. I just want to navigate the xml like a normal node-set.
Where am I going wrong?
Hi,
Does anyone know a library to compare addresses in Java ?
Something that would give equality on addresses, written in different ways.
For example, it should recognize that
"22 Acacia Avenue" and "22 acacia av."
is the same address.
Of course, this can escalate a lot, that's why i'm asking.
Thanks in advance.
I am exploring a structure of folders with C# projects such as the following:
Projects
ProjectA
ProjectB
ProjectC
ProjectD
Scattered around in the same folders as the .csproj files, there are several solution (.sln) files. Is there a fast way to find all the solutions that contain ProjectD.csproj? I can open them one by one and see what they contain, but I would like a feature such as "find all the solutions containing this project".
I need encrypt data using exactly the PKCS#1 V2.0 encryption method (defined in item 7.2.1 of the PKCS#1V2 specification).
Is it already implemented for Java?
I'm thinking in something like just pass a parameter to javax.crypto.Cipher specifying "PKCS#1V2", I wonder if there is something like this?
Hi.
I have a table in DB which contains summaries for days. Some days may not have the values.
I need to display table with results where each column is a day from user selected range.
I've tried to play with timestamp (end_date - start_date / 86400 - how many days in report, then use DATEDIFF(row_date, 'user_entered_start_date') and create array from this indexes), but now I've got whole bunch of workarounds for summer time :( Any examples or ideas how to make this correct?
P.S. I need to do this on PHP side, because DB is highly loaded.
I am working on a project where I need to embed a web server into my C# application so the application could display it's status via HTTP. I suppose I'll want to configure it through the http also.
I am looking for an open-source library written in C# and with a licensing scheme that will allow me to link it into my existing closed source code (LGPL). Any suggestions of specific products or where to look first?
It would be great if that product could have some kind of scripting, at least templates. All html output would go from the application, only resources would be stored on the disk (images, icons, ...)
EDIT:
I would like it to run under .NET 2.0, however.
Say I somehow got an object reference from an other class:
Object myObj = anObject;
Now I can get the class of this object:
Class objClass = myObj.getClass();
Now, I can get all constructors of this class:
Constructor[] constructors = objClass.getConstructors();
Now, I can loop every constructor:
if (constructors.length > 0)
{
for (int i = 0; i < constructors.length; i++)
{
System.out.println(constructors[i]);
}
}
This is already giving me a good summary of the constructor, for example a constructor public Test(String paramName) is shown as public Test(java.lang.String)
Instead of giving me the class type however, I want to get the name of the parameter.. in this case "paramName". How would I do that? I tried the following without success:
if (constructors.length > 0)
{
for (int iCon = 0; iCon < constructors.length; iCon++)
{
Class[] params = constructors[iCon].getParameterTypes();
if (params.length > 0)
{
for (int iPar = 0; iPar < params.length; iPar++)
{
Field fields[] = params[iPar].getDeclaredFields();
for (int iFields = 0; iFields < fields.length; iFields++)
{
String fieldName = fields[i].getName();
System.out.println(fieldName);
}
}
}
}
}
Unfortunately, this is not giving me the expected result. Could anyone tell me how I should do this or what I am doing wrong? Thanks!
As you know, the @ characters before a php istruction suppress every eventual warning, error or notice from being raised.
Personally, i dont like this tecnique, becose i prefer to handle those errors, and in a real life, the error must no happen or have to be managed.
By the way, i find this tecnique to be applied in many scripts (cms plugins, open-source classes).
So, could the @ really be usefull (in this case, an example would be appreciated), or is just for lazy developers?
I am trying to create a macro that brings in the name of the sheet and combine it with text. For example, for sheet one, I want it to say "ThisIs_Sheet1_Test" in I5 of Sheet1. There are several sheets but it should work for all of them.
What is wrong with my code? I think the underscore might be ruining it all. Here's what I have:
Dim SheetName As String
Public Sub CommandButton1_Click()
SheetName = ActiveSheet.Name
Sheets("Sheet1").Range("I5", "I5") = ThisIs_" & SheetName.text & "_Test
Sheets("Sheet2").Range("H5", "H5") = ThisIs_" & SheetName.text & "_Test
Sheets("Sheet3").Range("G5", "G5") = ThisIs_" & SheetName.text & "_Test
End Sub
I have a mysql table set up like so:
user_id | document
44 [blob]
44 [blob]
44 [blob]
46 [blob]
I'd like to export all of user_id 44's data to an SQLite3 file.
Best way to go about this without writing a script that reads the data and dumps it into a SQLite file?
Is this possible? Surely if you passed in a double, any sort of function implementation code which casts an object to an Integer would not be able to work unless the cast 'Integer' was specifically used? I have a function like:
public static void increment(Object o){
Integer one = (Integer)o;
system.out.println(one++);
}
I cant see how this could be made generic for a double? I tried
public static <E> void increment(E obj){
E one = (E)o;
system.out.println(one++);
}
but it didn't like it?
I have a servlet that receives some POST data. Because this data is x-www-form-urlencoded, a string such as ???? would be encoded to サボテン.
How would I unencode this string back to the correct characters? I have tried using URLDecoder.decode("encoded string", "UTF-8"); but it doesn't make a difference.
The reason I would like to unencode them, is because, before I display this data on a webpage, I escape & to & and at the moment, it is escaping the &s in the encoded string so the characters are not showing up properly.
do you got the solution for your problem ?
im working on the exact same thing and cant get it to work...
if u could post the solution, it would be much appreciated :o
greetingz
msn: [email protected]
steam : [email protected]