question: how can i bind the same vector, lets say o=c(1,2,3,4) mutiple times to get a matrix like
o=array(c(1,2,3,4,1,2,3,4,1,2,3,4), dim(c(4,3))
o
[,1] [,2] [,3]
[1,] 1 1 1
[2,] 2 2 2
[3,] 3 3 3
[4,] 4 4 4
in a nicer way then: o=cbind(o,o,o) and maybe more generalized (dublicate()??
I need this to specifiy colors for elements in textplot()
thx a lot
In Asp.net (c#),i'm not able to catch exception(FileNotFoundException) properly... i don't know the reason..Actually File s not there..But catch statement fails to catch the exception..
here is the code..
try
{
System.Drawing.Image imgg1 = System.Drawing.Image.FromFile(Server.MapPath("").ToString() + "\\images\\img1.jpg");
}
catch (FileNotFoundException)
{
Response.Write("<script>alert('Please Select and upload Student's Photo');</script>");
}
Hi ,
I am developing an application in cocoa which uses some java classes .I need to set the app point to
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0
instead of:
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK.
Is it possible to do this..
Thanks in advance
I'd like to fill System.Windows.Forms.ListView with the items I've stored in a separate System.Collections.Generics.List<. I would like to avoid to store the data twice, once in the List< and once as a string in ListViewItem. Is there a way to make ListViewItem use some callback function to obtain the text to put in its columns from the Tag property, instead of using its Text property?
I wanna sth like Spring framework to use in client side. Actually I am going to abstract ui from data sources that may be added to system while it is up. An XML will be injected to system and ui will be generated automatically. Client side use would be able to search on new data source while objects are created in client side.
Thanks
HI I am a new java programmer (very new).
What I want to do/test is (not sure if its recommendable or doable?), we know that
System.out.println("Message");
will output the "Message" in command prompt. Is it possible to display the current time, without having to repeatly use the system.out.println()?
Name, like instead of displaying:
10:00:01
10:00:02
10:00:03
I wand to have liek this:
10:00:0X where X will continue counting
Hi all, I have this functions and need to make it one function. The only difference is type of input variable sourceColumnValue. This variable can be String or Integer but the return value of function must be always Integer.
I know I need to use Generics but can't do it.
public Integer selectReturnInt(String tableName, String sourceColumnName, String sourceColumnValue, String targetColumnName) {
Integer returned = null;
String query = "SELECT "+targetColumnName+" FROM "+tableName+" WHERE "+sourceColumnName+"='"+sourceColumnValue+"' LIMIT 1";
try {
Connection connection = ConnectionManager.getInstance().open();
java.sql.Statement statement = connection.createStatement();
statement.execute(query.toString());
ResultSet rs = statement.getResultSet();
while(rs.next()){
returned = rs.getInt(targetColumnName);
}
rs.close();
statement.close();
ConnectionManager.getInstance().close(connection);
} catch (SQLException e) {
System.out.println("???????? ?? ???? ?? ???? ?????????!");
System.out.println(e);
}
return returned;
}
// SELECT (RETURN INTEGER)
public Integer selectIntReturnInt(String tableName, String sourceColumnName, Integer sourceColumnValue, String targetColumnName) {
Integer returned = null;
String query = "SELECT "+targetColumnName+" FROM "+tableName+" WHERE "+sourceColumnName+"='"+sourceColumnValue+"' LIMIT 1";
try {
Connection connection = ConnectionManager.getInstance().open();
java.sql.Statement statement = connection.createStatement();
statement.execute(query.toString());
ResultSet rs = statement.getResultSet();
while(rs.next()){
returned = rs.getInt(targetColumnName);
}
rs.close();
statement.close();
ConnectionManager.getInstance().close(connection);
} catch (SQLException e) {
System.out.println("???????? ?? ???? ?? ???? ?????????!");
System.out.println(e);
}
return returned;
}
is there some way to do databinding with linq2SQL or EntityFramework using "typed links" to the bound property?
Public Class Form1
Dim db As New MESDBEntities 'datacontext/ObjectContext
Dim bs As New BindingSource
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
bs.DataSource = (From m In db.PROB_GROUP Select m)
grid.DataSource = bs
TextBox1.DataBindings.Add("Text", bs, "PGR_NAME")
TextBox1.DataBindings.Add("Text", bs, db.PROB_GROUP) '**<--- Somthing like this**
End Sub
End Class
I'd like to have type checking when compiling and the model changed.
Hi guys,
I have a View with a Master Page. The user control makes use of a Model:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BudgieMoneySite.Models.SiteUserLoginModel>" %>
This user control is shown on all screens (Part of the Master Page). If the user is logged in, it shows a certain text, and if the user isn't logged in, it offers a login box.
That is working OK.
Now, I am adding my first functional screen. So I created a new view... and, well, i generated the basic view code for me when I selected the controller method, and said 'Create View'.
My Controller has this code:
public ActionResult Transactions()
{
List<AccountTransactionDetails> trans = GetTransactions();
return View(trans);
}
private List<AccountTransactionDetails> GetTransactions()
{
List<AccountTransactionDto> trans = Services.TransactionServices.GetTransactions();
List<AccountTransactionDetails> reply = new List<AccountTransactionDetails>();
foreach(var t in trans)
{
AccountTransactionDetails a = new AccountTransactionDetails();
foreach (var line in a.Transactions)
{
AccountTransactionLine l = new AccountTransactionLine();
l.Amount = line.Amount;
l.SubCategory = line.SubCategory;
l.SubCategoryId = line.SubCategoryId;
a.Transactions.Add(l);
}
reply.Add(a);
}
return reply;
}
So, my view was generated with this:
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<System.Collections.Generic.List<BudgieMoneySite.Models.AccountTransactionDetails>>" %>
Found <%=Model.Count() % Transactions.
All I want to show for now is the number of records I will be displaying.
When I run it, I get an error:
"The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[BudgieMoneySite.Models.AccountTransactionDetails]', but this dictionary requires a model item of type 'BudgieMoneySite.Models.SiteUserLoginModel'."
It looks like the user control is being rendered first, and as the Model from the controller is my List<, it's breaking!
What am I doing wrong?
I want to read following file in C++.
000001011100110
100000010101100
001001001001100
110110000000011
000000010110011
011000110101110
111010011011110
011001010010000
I know already how many rows and columns is there in the file. I want to read each integer and store it in a 2-D matrix of ints.
Each integers here means 0 is one entry and 1 is another entry. So in this example above there are 15 0's and 1s.
I'm looking for a comparison of the features of mobile browsers. Most interesting are the default preinstalled browsers. I would love a matrix that shows what device line can do what with their preinstalled browser.
There is a list with rendering engines on wikipedia but there should be differences appart from the rendering right?
Hi ,
I have silverlight app that post some data to another web application ,the data to post is converted to base 64 using code
byte[] byteArray = Encoding.UTF8.GetBytes(sDataToPost);
sDataToPost = Convert.ToBase64String(byteArray);
Another webapplication
get the data using the code
strText = System.Text.Encoding.ASCII.GetString(System.Convert.FromBase64String(postedData));
But it gives the exception invalid length for a base-64 char array
Thanks in Advance
DNM
i will need to store 3 tables of data
instead of implementing an entire database backend, i just want to store the record for these tables in application.settings
has anyone done this before?
i dont care about security
is it advisable to do it with application settings? how else would you do it?
perhaps storing a matrix in application.settings would be OK?
The first definition below produces the warning in the title when compiled with f# 3.0 and the warning level set to 5. The second definition compiles cleanly. I wondered if someone could please explain just what the compiler worries I might accidentally mutate, or how would splitting the expression with a let clause help avoid that. Many thanks.
let ticks_with_warning () : int64 =
System.DateTime.Now.Ticks
let ticks_clean () : int64 =
let t = System.DateTime.Now
t.Ticks
Server side code
public static boolean sendFile() {
int start = Integer.parseInt(startAndEnd[0]) - 1;
int end = Integer.parseInt(startAndEnd[1]) - 1;
int size = (end - start) + 1;
try {
bos = new BufferedOutputStream(initSocket.getOutputStream());
bos.write(byteArr,start,size);
bos.flush();
bos.close();
initSocket.close();
System.out.println("Send file to : " + initSocket);
} catch (IOException e) {
System.out.println(e.getLocalizedMessage());
disconnected();
return false;
}
return true;
}
Client Side
public boolean receiveFile() {
int current = 0;
try {
int bytesRead = bis.read(byteArr,0,byteArr.length);
System.out.println("Receive file from : " + client);
current = bytesRead;
do {
bytesRead =
bis.read(byteArr, current, (byteArr.length-current));
if(bytesRead >= 0) current += bytesRead;
} while(bytesRead != -1);
bis.close();
bos.write(byteArr, 0 , current);
bos.flush();
bos.close();
} catch (IOException e) {
System.out.println(e.getLocalizedMessage());
disconnected();
return false;
}
return true;
}
Client side is multithreading,server side not use multithreading. I just paste some code that made problem if you want see all code please tell me.
After I debug the code, I found that if I set max thread to any and then the first thread always stuck in this loop. That bis.read(....) always return 0. Although, server had close stream and it not get out of the loop. I don't know why ... But another threads are work correctly.
do {
bytesRead =
bis.read(byteArr, current, (byteArr.length-current));
if(bytesRead >= 0) current += bytesRead;
} while(bytesRead != -1);
i converted a string to BigInteger as follows:
Scanner sc=new Scanner(System.in);
System.out.println("enter the message");
String msg=sc.next();
byte[] bytemsg=msg.getBytes();
BigInteger m=new BigInteger(bytemsg);
now i want my string back.i m using m.toString() method but not getting desired result.
why??? what is bug in it and what is its remedy.
I'm trying to a binary file consisting of floats with Octave (on OS X), but I'm getting the following error:
octave-3.2.3:2> load Input.dat R -binary
error: load: failed to read matrix from file `Input.dat'
The file was written like so:
std::ofstream fout("Input.dat", std::ios::trunc | std::ios::binary);
fout.write(reinterpret_cast<char*>(Buf), N*sizeof(double));
fout.close();
Any idea what could be going wrong here?
Is there a way to reconstruct the command line arguments passed to Java within a Java program, including the JVM options and classpath option?
I have a Java program that needs to restart the JVM and manipulate its bootclasspath (i.e. trying to override some system classes). I use the libc system method to invoke the new JVM.
I'm open for better approaches, but Java agents isn't an option.
this.size = 9;
this.populationSize = 10;
Random rand = new Random();
Integer[][] easy1 = new Integer[size][size];
easy1 = this.initializeEasy1(easy1);
this.sudokuArray = new Sudoku[this.populationSize];
for (int i = 0; i < this.sudokuArray.length; i++){
long seed = rand.nextLong();
System.out.println("" + seed);
this.sudokuArray[i] = new Sudoku(easy1, this.size, seed);
}
I am building an evolutionary sudoku solver and I am having a problem where the last Sudoku object is overwriting all the other objects in the array. Where in the code did I mess up?
/edit here is the constructor of the class
public Sudoku(Integer[][] givensGrid, int s, long seed){
this.size = s;
this.givens = givensGrid;
this.grid = this.givens.clone();
Random rand = new Random(seed);
System.out.println("Random " + rand.nextInt());
// step though each row of the grid
for (int i = 0; i < size; i++){
ArrayList<Integer> numbers = new ArrayList<Integer>();
numbers = this.makeNumbers(numbers);
// step through each column to find the givens and remove from numbers
for (int j = 0; j < size; j++){
if (this.grid[i][j] != 0){
numbers.remove(this.grid[i][j]);
}
}
// go back through the row and assign the numbers randomly
for (int j = 0; j < size; j++){
if (this.grid[i][j] == 0){
int r = rand.nextInt(numbers.size());
this.grid[i][j] = numbers.get(r);
numbers.remove(r);
}
}
}
System.out.println("=============");
System.out.println(this.toString());
}
For a new project which uses Maven I would like to add distributionManagement configuration in the pom.xml which will connect the project with the Sourceforge.net file upload system.
I have found this information (of 2007), is it still valid or do you know updated resources?
http://docs.codehaus.org/display/MAVENUSER/MavenAndSourceforge
Related question: How can I deploy artifacts from a Maven build to the SourceForge File Release System?
You usually invoke the following commands to build a ./configured product:
make
make install
Okay, the product is in the system now. Then you change some source code files and invoke only make install. The question is, does the conventional implementation of install target requires the executables to be recompiled, or just the old ones should be copied to the appropriate system path?
Hi,
I have the code below:
using (SqlCommand command = new SqlCommand())
{
command.CommandType = System.Data.CommandType.StoredProcedure;
command.Connection = new SqlConnection();
command.CommandText = "";
command.Parameters.Add(new SqlParameter("@ExperienceLevel", 3).Direction = System.Data.ParameterDirection.Input);
SqlDataReader dataReader = command.ExecuteReader();
}
Is there any functional impact in declaring the SqlConnection where I currently am declaring it as opposed to like so?:
using (SqlCommand command = new SqlCommand())
using (SqlConnection connection = new SqlConnection())
Thanks
Thanks in Advance...Need speech recognition and convert into text in windows mobile 6.0. I already done it for windows desktop application using System.Speech.Recognition. Will System.Speech support for windows mobile.. Please Reply If any other solution available.