I have a very simple console app where I'm using dataset.WriteXml(@"c:\temp") but I'm getting message "Access Denied". What do I need to do?
Using Visual Studio 2008 on XP Pro.
public class Prime {
public static boolean isPrime1(int n) {
if (n <= 1) {
return false;
}
if (n == 2) {
return true;
}
for (int i = 2; i <= Math.sqrt(n) + 1; i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
public static boolean isPrime2(int n) {
if (n <= 1) {
return false;
}
if (n == 2) {
return true;
}
if (n % 2 == 0) {
return false;
}
for (int i = 3; i <= Math.sqrt(n) + 1; i = i + 2) {
if (n % i == 0) {
return false;
}
}
return true;
}
}
public class PrimeTest {
public PrimeTest() {
}
@Test
public void testIsPrime() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Prime prime = new Prime();
TreeMap<Long, String> methodMap = new TreeMap<Long, String>();
for (Method method : Prime.class.getDeclaredMethods()) {
long startTime = System.currentTimeMillis();
int primeCount = 0;
for (int i = 0; i < 1000000; i++) {
if ((Boolean) method.invoke(prime, i)) {
primeCount++;
}
}
long endTime = System.currentTimeMillis();
Assert.assertEquals(method.getName() + " failed ", 78498, primeCount);
methodMap.put(endTime - startTime, method.getName());
}
for (Entry<Long, String> entry : methodMap.entrySet()) {
System.out.println(entry.getValue() + " " + entry.getKey() + " Milli seconds ");
}
}
}
I am trying to find the fastest way to check whether the given number is prime or not. This
is what is finally came up with. Is there any better way than the second implementation(isPrime2).
Hi there!
I've got an XML file that is parsed and written in my application. From within my IDE (Eclipse) I simply address it like this:
Reading:
private String xmlFile = "file.xml";
and then I build the document:
doc = sax.build(xmlFile);
Writing is done like this:
writer = new FileWriter("file.xml");
Runs great so far, but after bundling my application, the file is no longer accessible.
What exactly do I have to do to make it accessible from within an application bundle?
I'm absolutely not familiar with the classpath or whatever I need for that, so please go easy on me!
Thank you very much!
My company is planning in hiring outsourcers to work for us, but concerned to give whole existing code to outside world.
What is the proper way to deal with security of sharing code in such cases?
Is it possible to restrict part of code for developers? So each of them could work on their project without having access to whole repository.
P.S. The code we have is very integrated, and its hard to extract "one module", each module can use files from different locations.
Thanks in advance
Is there anything in Java that implements something like the following
interface MSet<T> extends Iterable<T> {
/**
* return a new set which consists of this set plus a new element.
* This set is not changed.
*/
MSet<T> add(T t);
/**
* return a new set which consists of this set minus a designated element.
* This set is not changed.
*/
MSet<T> remove(T t);
}
(r'^/(?P<the_param>[a-zA-z0-9_-]+)/$','myproject.myapp.views.myview'),
How can I change this so that "the_param" accepts a URL(encoded) as a parameter?
So, I want to pass a URL to it.
mydomain.com/http%3A//google.com
during debug mode or while i am doing testing, i need to print lost of various information, so i use this method
ifdef TESTING
// code with lots of debugging info
else
// clean code only
endif // TESTING`
Is this the good method, or is there any other simple and elegant method.
But this way, I am repating the same code in two places and if anything is to be changed later on in the code, I have to do it in both places, which is time consuming and error prone.
Thanks.
I am using MS Visual Studio.
No need for images.
Needs to have posting + answering + commenting + voting system.
No need for badges.
Powered by database of your choice.
referring to stackoverflow.com / stackexchange.com is lame.
hi,
so i have a table lets say call it "tbl.items" and there is a column "title" in "tbl.items" i want to loop through each row and for each "title" in "tbl.items" i want to do following:
the column has the datatype nvarchar(max) and contains a string...
filter the string to remove words like in,out, where etc (stopwords)
compare the rest of the string to a predefined list and if there is a match perform some action which involves inserting data in other tables as well..
the problem is im ignotent when it comes to writing T-sql scripts, plz help and guide me how can i achieve this?
whether it can be achieved by writing a sql script??
or i have to develope a console application in c# or anyother language??
im using mssql server 2008
thanks in advance
Hi,
i am using subversion as RCS. Always when a new version of my project is finised i create a tag of it (copy of the trunk).
Does anybody know how i can protect this tagged directory from being accidentally modified?
At the moment as a workaround i lock all files. But this sill means that the user with the lock can edit the files.
Is there any better solution?
Finishing up some homework and Im having trouble with figuring out how to take information generated in sql column(a primary key set up to assign a record number to a customer example 1046) at submit and writing it to my redirected recipt page. I call it recipt.aspx. Any takers
Professor says to use a datareader...but things go bad after that.
public partial class _Default : System.Web.UI.Page
{
String cnStr = "EDITED FOR THE PURPOSE OF NOT DISPLAYED SQL SERVERta Source=111.11.111.11; uid=xxxxxxx; password=xxxx; database=xxxxxx; ";
String insertStr;
SqlDataReader reader;
SqlConnection myConnection = new SqlConnection();
protected void submitbutton_Click(object sender, EventArgs e)
{
myConnection.ConnectionString = cnStr;
try
{
//more magic happens as myConnection opens
myConnection.Open();
insertStr = "insert into connectAssignment values ('" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + bigtextthing.Text + "','" + DropDownList1.SelectedItem.Value + "')";
//magic happens as Connection string is assigned to connection object and passes in the SQL statment
//associate the command to the the myConnection connection object
SqlCommand cmd = new SqlCommand(insertStr, myConnection);
cmd.ExecuteNonQuery();
Session["passmyvalue1"] = TextBox2.Text;
Session["passmyvalue2"] = TextBox3.Text;
Session["passmyvalue3"] = TextBox4.Text;
Session["passmyvalue4"] = TextBox5.Text;
Session["passmyvalue5"] = bigtextthing.Text;
Session["I NEED SOME HELP RIGHT HERE"] =Textbox6.Text;
Response.Redirect("receipt.aspx");
}
catch
{
bigtextthing.Text =
"Error submitting" + "Possible casues: Internet is down,server is down, check your settings!";
}
finally
{
myConnection.Close();
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
bigtextthing.Text = "";
}
//reset validators?
}
The recipt page
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(Session["passmyvalue1"] != null)
{
TextBox1.Text = (string)Session["passmyvalue1"];
TextBox2.Text = (string)Session["passmyvalue2"];
TextBox3.Text = (string)Session["passmyvalue3"];
TextBox4.Text = (string)Session["passmyvalue4"];
TextBox5.Text = (string)Session["passmyvalue5"];
TextBox6.Text = I don't know ;
}
}
}
THanks for the help
I would like to make my local jpg and mp3 files kind of unreadable (without encoding) by just putting the first 100 bytes from the beginning of the file to the end and then saving the file with a .dat extension. I know I have to use the byte array but can't get it work.
I would also need then a small function to read that file and put the 100bytes back to the front so that I can play/display the file.
It would be great if you could post the whole function because I am quite new to Air so that I fully understand.
Thank You!!!!
I am trying:
saveArr = do
outh <- openFile "test.txt" WriteMode
hPutStrLn outh [1,2,3]
hClose outh
but it doesn't works... output:
No instance for (Num Char) arising from the literal `1'
I need to read the data out of database and then save it in a text file, how can I do that in Ruby? Is there any file management system in Ruby?
Thanks
What is the best way to define connection string for a web application that has minimum 500 live users on the internet in terms of connection pooling.
And load factors to consider?
Suppose I have connection string as follows:
initial catalog=Northwind; Min Pool Size=20;Max Pool Size=500; data source=localhost; Connection Timeout=30; Integrated security=sspi"
as Max Pool Size is 500 and as live users exceed 500 say 520 will the remaining 20 users experience slower page load??
Or what if I have connection string as follows which doesn't talks anything about pooling or Connection time out? How the application behaves then?
initial catalog=Northwind; data source=localhost; Integrated security=sspi"
I'm using "Using statements" however to access the MYSQL database.
HI,
I just wonder if that is possible.
I know simple types can be read through com interface. Does anyone have experience with complex types as structs and classes?
I am writing a download manager for iPhone using objective C. I am using ASIHTTP framework and its working great. But my problem is I am not able to download from file sharing sites like filesonic, rapidshare, hotfile etc.
I want to know how can I get download (actual download) url from these sites, or at least how these sites are hiding this info (and where), so I can get that somehow...
Is there any open source library or framework to help me with this? How firefox or other desktop browser get this link?
Any help will be much appreciated!
Update 1 : I don't want to bypass their advertising and revenue streams. Almost all file sharing companies also provide free downloads with low bandwidth, I only want to use that service. there are many download managers available now for iPhone like - "Downloads Lite". I just want to build a similar functionality.
I want to produce a JSON file, containing some initial parameters and then records of data like this:
{
"measurement" : 15000,
"imi" : 0.5,
"times" : 30,
"recalibrate" : false,
{
"colorlist" : [234, 431, 134]
"speclist" : [0.34, 0.42, 0.45, 0.34, 0.78]
}
{
"colorlist" : [214, 451, 114]
"speclist" : [0.44, 0.32, 0.45, 0.37, 0.53]
}
...
}
How can this be achieved using the Python json module? The data records cannot be added by hand as there are very many.
Though this might appear as a duplicate of Java Web Services , I would like to know Where to start and to continue.In the past, I have invested so much of time to find where to start but I wasn't able to. There are so many jargons and chaos (at least for me!) while reading the pages about web services. There are so many terms - like JAX-RPC, JAX-WS, Axis, Rest, Servlet as WebService, EJB's as Web Service and other terms that I don't know. Can this User group consolidate and give a highlevel overview of Java Web Services which is easy to understand and follow? I appreciate your kindness and thanks for your help.
Is there is way to compress JavaScript code?
e.g.
function test(){
// some code here
}
after compression it should be
function test(){//some code here}
Also, I need vise versa at the time of editing the code.
Hi,
I have the following code that I want to return to a variable "t" in jQery:
Code behind:
Public Shared Function GetSomeText() As String
Dim result = "This is from code behind"
Return result
End Function
Caller variable in jQuery:
//This is not working like that, I think
var t = GetSomeText();
So, how can I make variable "t" get the "result" from Function GetSomeText from code-behind?
Thank you.
I have an written an Object called Shape which has a Point representing the topLeftCorner and a Dimension with represents its width and height.
To get the topRightCorner I can simply add the width to the topLeftPoint.x. I use to rotate them on a certain degree around their center. The problem after the rotation is, that my intersects(Shape) method fails, because it does not honor the rotation of the Shapes. The rotation will be the same for each Shape. My current implementation looks like this inside my Shape Object:
public boolean intersects(Shape s){
// functions returning a Point of shape s
return intersects(s.topLeft())
|| intersects(s.topRight())
|| intersects(s.bottomLeft())
|| intersects(s.bottomRight())
|| intersects(s.leftCenter())
|| intersects(s.rightCenter())
|| intersects(s.center());
}
public boolean intersects(Point p){
return p.x >= leftX()
&& p.x <= rightX()
&& p.y >= topY()
&& p.y <= bottomY();
}
Basically I need functions like rotatedLeftX() or rotatedTopRight() to work properly. Also for that calculation I think it doesn't matter when the topLeft point before a rotation of ie 90 will turn into topRight...
I already read this and this Question here, but do not understand it fully.
S.no Area
1 55
2 65
3 51
4 70
5 55
6 65
7 75
8 60
9 45
10 50
11 70
12 52
13 65
14 40
15 60
16 55
17 50
18 65
19 85
20 81
By entering range of Sno. e.g 3 to 5 I MUST GET THE ADDITION OF Area for specified range of Sno.
Note : range of sno. may vary like 3 to 5 , 10 to 18 etc.
I'm running kubuntu 9.10 in VirtualBox, i wrote the simplest "hello world" program in C, the code compiles, i ran it through a debugger and it seems to run fine. the only problem is nothing gets actually printed to the console...
any ideas ?
heres the code:
#include <stdlib.h>
int main (int argc, char **argv) {
printf("hello world");
return 0;
}