Hi!
Is it good when url to show and destroy are same? How it can be changed in RoR if i want continue use standard tools like script/generate scaffold ?
Thanks.
I am trying to understand what the process is of turning HTML into a PDF/Postscript programmatically
All Google searches turn up libraries to do this, but I am more interested in the actual process required.
I know you could just set up a Postscript printer and print directly to that, but some of these libraries appear to create the PDF on the fly to allow previews etc.
has anyone had any experience in this, or can provide any guidance?
Let's say you have this program:
public class sample
public static void main(String args[])
{
System.out.println("Hello world!");
}
}
... is there a converter that will turn it into this:
import java.applet.Applet;
import javax.swing.*;
public class sample extends JApplet
{
public static JTextArea area;
public void init()
{
area = new JTextArea();
add(area);
area.append("Hello world!");
}
}
I mean, I can do it by hand... but it would take some time.
I am trying to create a class in VB.NET which inherits a base abstract class and also implements an interface. The interface declares a string property called Description. The base class contains a string property called Description. The main class inherits the base class and implements the interface. The existence of the Description property in the base class fulfills the interface requirements. This works fine in C# but causes issues in VB.NET.
First, here is an example of the C# code which works:
public interface IFoo
{
string Description { get; set; }
}
public abstract class FooBase
{
public string Description { get; set; }
}
public class MyFoo : FooBase, IFoo
{
}
Now here is the VB.NET version which gives a compiler error:
Public Interface IFoo
Property Description() As String
End Interface
Public MustInherit Class FooBase
Private _Description As String
Public Property Description() As String
Get
Return _Description
End Get
Set(ByVal value As String)
_Description = value
End Set
End Property
End Class
Public Class MyFoo
Inherits FooBase
Implements IFoo
End Class
If I make the base class (FooBase) implement the interface and add the Implements IFoo.Description to the property all is good, but I do not want the base class to implement the interface.
The compiler error is:
Class 'MyFoo' must implement 'Property Description() As String' for interface 'IFoo'. Implementing property must have matching 'ReadOnly' or 'WriteOnly' specifiers.
Can VB.NET not handle this, or do I need to change my syntax somewhere to get this to work?
I'm looking to export a page that looks good in print media, to word.
Can this be done automatically, or mostly automatically with office apis?
The alternative is to create a program that reads all our style meta data and font meta data and convert to word and force a download.
The issue is our style metadata is already built for css, its a web app after all. And writing my own css parser, doesn't sound like a good use of time.
I have a program that handles byte arrays in Java, and now I would like to write this into a XML file. However, I am unsure as to how I can convert the following byte array into a sensible String to write to a file. Assuming that it was Unicode characters I attempted the following code:
String temp = new String(encodedBytes, "UTF-8");
Only to have the debugger show that the encodedBytes contain "\ufffd\ufffd ^\ufffd\ufffd-m\ufffd\ufffd\/ufffd \ufffd\ufffdIA\ufffd\ufffd". The String should contain a hash in alphanumerical format.
How would I turn the above String into a sensible String for output?
I am trying to convert a 24bit Hexadecimal string (6 characters) signed in two's complement to a long int in C.
This is the function I have come up with:
long int hex2li (char string[])
{
char *pEnd;
long int result = strtol (string, &pEnd, 16);
if (strcmp (pEnd, "") == 0)
{
if (toupper (string[0]) == 'F')
{
return result - 16777216;
}
else
{
return result;
}
}
return LONG_MIN;
}
Is it valid? Is there a better way of doing this?
as i said i get this horrible error i dont really know what to do anymore
float n= xAxis[i].Normalize();
thats where i get the error and i get it cuz normalize is a void function this is it
void CVector::normalize()
{
float len=Magnitude();
this->x /= len;
this->y /= len;
}
i need normalize to stay as void tho i tried normal casting like this
float n= (float)xAxis[i].Normalize();
and it doesnt work also with static,dynamic cast,reinterpret,const cast and cant make it work any help would be really apreciated...
thank you .<
I just started using C# and I've got a couple of issues.
I hook several controls to one event handler as in the following and I want to perform a slightly different action for each control:
Private Sub Button_Click(sender as Object, e as EventArgs) _
Handles button1.Click, Button2.Click
'do a general activity
Select CType(sender, Button).Name
Case button1.Name
'do something
Case button2.Name
'do something else
Case Else
'do the defalut action
End Select
End Sub
Is there any way of doing the above select statement in C# without having to use nested ifs?
I have a need to convert a string value in the form "YYYYMMDDHHMMSS" to a DateTime. But not sure on how, may be a DateTime.Tryparse can be used to make this happen. Or is there any other way to do it. I can do this using some string operations to take "YYYYMMDD" alone, convert to a datetime and then add HH, MM, SS separately to that DateTime. But is there any DateTime.TryParse() methods that I can use in one line to convert a "YYYYMMDDHHMMSS" format string value to a DateTime value?
I'm having trouble understanding the result of the following statements:
>>> from array import array
>>> array('L',[0xff,0xff,0xff,0xff])
array('L', [255L, 255L, 255L, 255L])
>>> from array import array
>>> array('L','\xff\xff\xff\xff')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: string length not a multiple of item size
Good day everyone and happy holidays.
I'm trying to create a "simple" program that allows me to create a list of video files (Youtube video's to be precise) that are then run through by my program and converted any given format to pure MP3 audio. For this purpose I'm trying to use the BASS.dll and well it isn't going so well.
I was wondering if anyone has used BASS to convert from one audio format to another?
Or is there another library better suited for this?
I'm writing a C# frontend to a legacy database that uses VB6 Rnd() and Randomize() methods for user password encryption. The encryption function is very simplistic and really not all that secure, but it's what all current passwords are stored with.
What I'd like to be able to do is authenticate legacy users from a C# application. I can write new encryption (or preferably hashing) code for VB6 so that all future users have a more secure password, and that can be duplicated in C#. But I don't want to require current users to have had their password reset before they can use the new frontend.
Is there any way I can reimplement that algorithm in C# so that it produces identical results to the legacy VB6 code?
Hi,
I cannot initialize a non-const reference to type T1 from a convertible type T2. However, I can with a const reference.
long l;
const long long &const_ref = l; // fine
long long &ref = l; // error: invalid initialization of reference of
// type 'long long int&' from expression of type
// 'long int'
Most problems I encountered were related to r-values that cannot be assigned to a non-const reference. This is not the case here -- can someone explain? Thanks.
I have a SQL Server 2000 database with a column of type VARCHAR(255). All the data is either NULL, or numeric data with up to two points of precision (e.g. '11.85'). I tried to run the following T-SQL query but received the error 'Error converting data type varchar to numeric'
SELECT CAST([MyColumn] AS DECIMAL)
FROM [MyTable];
I tried a more specific cast, which also failed.
SELECT CAST([MyColumn] AS DECIMAL(6,2))
FROM [MyTable];
I also tried the following to see if any data is non-numeric, and the only values returned were NULL.
SELECT ISNUMERIC([MyColumn]), [MyColumn]
FROM [MyTable]
WHERE ISNUMERIC([MyColumn]) = 0;
I tried to convert to other data types, such as FLOAT and MONEY, but only MONEY was successful. So I tried the following:
SELECT CAST(CAST([MyColumn] AS MONEY) AS DECIMAL)
FROM [MyTable];
...which worked just fine. Any ideas why the original query failed? Will there be a problem if I first convert to MONEY and then to DECIMAL?
Thanks!
I'm using XML::XML2JSON in Perl to convert JSON data to XML, I am passing through the following data (snippet):
{"question":{"isrequired":{"$t":"0"}}}
and when I use the XML:XML2JSON-json2xml function to convert the JSON data into XML, I get the following (snippet):
<isrequired/>
I need to retain the "0" element in the "isrequired" tag, because at times, I will have empty JSON elements, and need the empty XML tag. I think the documentation is a bit vague (either that, or I don't understand it), but is this possible to do with this module?
I would appreciate the help. Thanks.
I was wondering if anyone would be able to help me convert the below code to c#? From what I have read it seems to be similar however I am not sure if my 'case' statements are still able to be used?
Public Class Form1
Dim dteStart As Date
Dim dteFinish As Date
Dim span As TimeSpan
Public Sub KeyDown(ByVal Sender As System.Object, ByVal e As _
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
Case Keys.Q
Label1.BackColor = Color.Green
dteStart = Now()
Case Keys.W
Label2.BackColor = Color.Green
Case Keys.E
Label3.BackColor = Color.Green
Case Keys.R
Label4.BackColor = Color.Green
dteFinish = Now()
span = dteFinish.Subtract(dteStart)
Label5.Text = span.ToString
End Select
End Sub
Public Sub KeyUp(ByVal Sender As System.Object, ByVal e As _
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
Select Case e.KeyCode
Case Keys.Q
Label1.BackColor = Color.Red
Case Keys.W
Label2.BackColor = Color.Red
Case Keys.E
Label3.BackColor = Color.Red
Case Keys.R
Label4.BackColor = Color.Red
End Select
End Sub
End Class
Hi,
I made a small RGB to HSV converter algorithm with C. It seems to work pretty well, but there is one strange problem: If I first convert i.e. a 800x600 picture into HSV map and then back to RGB map without doing any changes in the values, I get some pixels that are convertet incorrectly. Then if I try to convert those misbehaving single pixels alone to and back, they're converted correctly. Any idea what could be the problem? I'm using Daniel Karlings PNGLite to open that PNG file.
Here are the source code of my main.c, rgbtohsv.c and rgbtohsv.h
rgbToHsv.h
rgbToHsv.c
pngmain.c
I linked pngmain only that if somebody wants to test and run this on his own system.
-zaplec
Hi,
I am trying to convert an integer number in C into an array containing each of that number's digits
i.e. if I have
int number = 5400
how can I get to
int numberArray[4]
where
numberArray[0] = 0;
numberArray[1] = 0;
numberArray[2] = 4;
numberArray[3] = 5;
Any suggestions gratefully received
--dave
Dear all,
Hello Guys!!
This is my first post in the forum . I am really looking forward to having good fun in this site. My question is :
int mem_size = 10;
char *start_ptr;
if((start_ptr= malloc(mem_size*1024*1024*sizeof(char)))==NULL) {return -1;}
I have allocated a chunk of memory of type char and size is say 10 MB (i.e mem_size = 10 );
Now I want to store the size information in the header of the memory chunk,
To make myself more clear
Lets Say : start_ptr = 0xaf868004 (This is the value I got from my execution, it changes every time)
Now I want to put the size information in the start of this pointer..
i.e *start_ptr = mem_size*1024*1024;
But I am not able to put this information in the start_ptr. I think the reason is because my ptr is of type char which only takes one byte but I am trying to store int which takes 4 bytes, is the problem .
I am not sure how to fix this problem..
I would greatly appreciate your suggestions.
Cheers!!
Aditya
I’m looking for a solution to send DRY multipart emails in Rails. With DRY I mean that the content for the mail is only defined once.
I’ve thought about some possible solutions but haven’t found any existing implementations.
The solutions I’ve thought about are:
load the text from I18n and apply Markdown for the html mail and apply Markdown with a special output type for the text mail where
links are put in parenthesis after the link text
bold, italic and other formatting that doesn't make sense are removed
ordered and unordered lists are maintained
generate only the html mail and convert that to text according to the above conditions
Is there any available solution out there? Which one is probably the better way to do it?